diff options
Diffstat (limited to 'tests/utils_tests/test_encoding.py')
| -rw-r--r-- | tests/utils_tests/test_encoding.py | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py index 1d6976fc77..b4e7b9c0ac 100644 --- a/tests/utils_tests/test_encoding.py +++ b/tests/utils_tests/test_encoding.py @@ -21,10 +21,8 @@ class TestEncodingUtils(unittest.TestCase): __unicode__ = __str__ - # str(s) raises a TypeError on python 3 if the result is not a text type. - # python 2 fails when it tries converting from str to unicode (via ASCII). - exception = TypeError if six.PY3 else UnicodeError - with self.assertRaises(exception): + # str(s) raises a TypeError if the result is not a text type. + with self.assertRaises(TypeError): force_text(MyString()) def test_force_text_lazy(self): @@ -47,26 +45,15 @@ class TestEncodingUtils(unittest.TestCase): def test_smart_text(self): class Test: - if six.PY3: - def __str__(self): - return 'ŠĐĆŽćžšđ' - else: - def __str__(self): - return 'ŠĐĆŽćžšđ'.encode('utf-8') + def __str__(self): + return 'ŠĐĆŽćžšđ' class TestU: - if six.PY3: - def __str__(self): - return 'ŠĐĆŽćžšđ' - - def __bytes__(self): - return b'Foo' - else: - def __str__(self): - return b'Foo' + def __str__(self): + return 'ŠĐĆŽćžšđ' - def __unicode__(self): - return '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111' + def __bytes__(self): + return b'Foo' self.assertEqual(smart_text(Test()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111') self.assertEqual(smart_text(TestU()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111') |
