/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_cache_utf8.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from .. import (
20
20
    cache_utf8,
21
21
    )
22
 
from ..sixish import text_type
23
22
from . import TestCase
24
23
 
25
24
 
73
72
        self.check_decode(u'some_\xb5_unicode_\xe5_chars')
74
73
 
75
74
    def test_cached_unicode(self):
76
 
        # Note that this is intentionally split, to prevent Python from
77
 
        # assigning x and y to the same object
78
 
        z = u'\xe5zz'
79
 
        x = u'\xb5yy' + z
80
 
        y = u'\xb5yy' + z
81
 
        self.assertIsNot(x, y)
 
75
        x = u'\xb5yy' + u'\xe5zz'
 
76
        y = u'\xb5yy' + u'\xe5zz'
 
77
        self.assertFalse(x is y)
82
78
        xp = cache_utf8.get_cached_unicode(x)
83
79
        yp = cache_utf8.get_cached_unicode(y)
84
80
 
96
92
        self.assertIs(xp, yp)
97
93
 
98
94
    def test_cached_ascii(self):
99
 
        x = b'%s %s' % (b'simple', b'text')
100
 
        y = b'%s %s' % (b'simple', b'text')
101
 
        self.assertIsNot(x, y)
 
95
        x = '%s %s' % ('simple', 'text')
 
96
        y = '%s %s' % ('simple', 'text')
 
97
        self.assertFalse(x is y)
102
98
        xp = cache_utf8.get_cached_ascii(x)
103
99
        yp = cache_utf8.get_cached_ascii(y)
104
100
 
109
105
        # objects.
110
106
        uni_x = cache_utf8.decode(x)
111
107
        self.assertEqual(u'simple text', uni_x)
112
 
        self.assertIsInstance(uni_x, text_type)
 
108
        self.assertIsInstance(uni_x, unicode)
113
109
 
114
110
        utf8_x = cache_utf8.encode(uni_x)
115
111
        self.assertIs(utf8_x, x)
116
112
 
117
113
    def test_decode_with_None(self):
118
114
        self.assertEqual(None, cache_utf8._utf8_decode_with_None(None))
119
 
        self.assertEqual(u'foo', cache_utf8._utf8_decode_with_None(b'foo'))
 
115
        self.assertEqual(u'foo', cache_utf8._utf8_decode_with_None('foo'))
120
116
        self.assertEqual(u'f\xb5',
121
 
                         cache_utf8._utf8_decode_with_None(b'f\xc2\xb5'))
 
117
                         cache_utf8._utf8_decode_with_None('f\xc2\xb5'))