~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_cache_utf8.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-09 16:41:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070209164100-t9t1760kq6y5qgwn
Add get_cached_ascii for dealing with how cElementTree handles ascii strings

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)
 
81
        self.assertIs(xp, x)
 
82
        self.assertIs(xp, yp)
83
83
 
84
84
    def test_cached_utf8(self):
85
85
        x = u'\xb5yy\xe5zz'.encode('utf8')
88
88
        xp = cache_utf8.get_cached_utf8(x)
89
89
        yp = cache_utf8.get_cached_utf8(y)
90
90
 
91
 
        self.failUnless(xp is x)
92
 
        self.failUnless(xp is yp)
 
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)