~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_cache_utf8.py

  • Committer: Brad Crittenden
  • Date: 2007-02-26 20:56:10 UTC
  • mfrom: (2300 +trunk)
  • mto: (2293.1.5 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 2311.
  • Revision ID: brad.crittenden@canonical.com-20070226205610-44oatbxrjjz3ajwy
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        xp = cache_utf8.get_cached_unicode(x)
79
79
        yp = cache_utf8.get_cached_unicode(y)
80
80
 
81
 
        self.failUnless(xp is x)
82
 
        self.failUnless(xp is yp)
83
 
 
 
81
        self.assertIs(xp, x)
 
82
        self.assertIs(xp, yp)
 
83
 
 
84
    def test_cached_utf8(self):
 
85
        x = u'\xb5yy\xe5zz'.encode('utf8')
 
86
        y = u'\xb5yy\xe5zz'.encode('utf8')
 
87
        self.failIf(x is y)
 
88
        xp = cache_utf8.get_cached_utf8(x)
 
89
        yp = cache_utf8.get_cached_utf8(y)
 
90
 
 
91
        self.assertIs(xp, x)
 
92
        self.assertIs(xp, yp)
 
93
 
 
94
    def test_cached_ascii(self):
 
95
        x = '%s %s' % ('simple', 'text')
 
96
        y = '%s %s' % ('simple', 'text')
 
97
        self.failIf(x is y)
 
98
        xp = cache_utf8.get_cached_ascii(x)
 
99
        yp = cache_utf8.get_cached_ascii(y)
 
100
 
 
101
        self.assertIs(xp, x)
 
102
        self.assertIs(xp, yp)
 
103
 
 
104
        # after caching, encode and decode should also return the right
 
105
        # objects.
 
106
        uni_x = cache_utf8.decode(x)
 
107
        self.assertEqual(u'simple text', uni_x)
 
108
        self.assertIsInstance(uni_x, unicode)
 
109
 
 
110
        utf8_x = cache_utf8.encode(uni_x)
 
111
        self.assertIs(utf8_x, x)