78
78
xp = cache_utf8.get_cached_unicode(x)
79
79
yp = cache_utf8.get_cached_unicode(y)
81
self.failUnless(xp is x)
82
self.failUnless(xp is yp)
84
def test_cached_utf8(self):
85
x = u'\xb5yy\xe5zz'.encode('utf8')
86
y = u'\xb5yy\xe5zz'.encode('utf8')
88
xp = cache_utf8.get_cached_utf8(x)
89
yp = cache_utf8.get_cached_utf8(y)
94
def test_cached_ascii(self):
95
x = '%s %s' % ('simple', 'text')
96
y = '%s %s' % ('simple', 'text')
98
xp = cache_utf8.get_cached_ascii(x)
99
yp = cache_utf8.get_cached_ascii(y)
102
self.assertIs(xp, yp)
104
# after caching, encode and decode should also return the right
106
uni_x = cache_utf8.decode(x)
107
self.assertEqual(u'simple text', uni_x)
108
self.assertIsInstance(uni_x, unicode)
110
utf8_x = cache_utf8.encode(uni_x)
111
self.assertIs(utf8_x, x)
113
def test_decode_with_None(self):
114
self.assertEqual(None, cache_utf8._utf8_decode_with_None(None))
115
self.assertEqual(u'foo', cache_utf8._utf8_decode_with_None('foo'))
116
self.assertEqual(u'f\xb5',
117
cache_utf8._utf8_decode_with_None('f\xc2\xb5'))