diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2017-01-26 10:08:08 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-02-06 14:12:06 -0500 |
| commit | 3bb6a4390c0a57da991fcb1c0642b9b3fccff751 (patch) | |
| tree | f958fe5cf95e3a5285e3bb595da4f7cf27567d58 /tests/utils_tests/test_encoding.py | |
| parent | 24b82cd201e21060fbc02117dc16d1702877a1f3 (diff) | |
Refs #27753 -- Favored force/smart_str() over force/smart_text().
Diffstat (limited to 'tests/utils_tests/test_encoding.py')
| -rw-r--r-- | tests/utils_tests/test_encoding.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py index c461df71ee..b40d49987f 100644 --- a/tests/utils_tests/test_encoding.py +++ b/tests/utils_tests/test_encoding.py @@ -6,7 +6,7 @@ from urllib.parse import quote_plus from django.test import SimpleTestCase from django.utils.encoding import ( DjangoUnicodeDecodeError, escape_uri_path, filepath_to_uri, force_bytes, - force_text, get_system_encoding, iri_to_uri, smart_bytes, smart_text, + force_str, get_system_encoding, iri_to_uri, smart_bytes, smart_str, uri_to_iri, ) from django.utils.functional import SimpleLazyObject @@ -14,7 +14,7 @@ from django.utils.translation import gettext_lazy class TestEncodingUtils(SimpleTestCase): - def test_force_text_exception(self): + def test_force_str_exception(self): """ Broken __str__ actually raises an error. """ @@ -24,19 +24,19 @@ class TestEncodingUtils(SimpleTestCase): # str(s) raises a TypeError if the result is not a text type. with self.assertRaises(TypeError): - force_text(MyString()) + force_str(MyString()) - def test_force_text_lazy(self): + def test_force_str_lazy(self): s = SimpleLazyObject(lambda: 'x') - self.assertIs(type(force_text(s)), str) + self.assertIs(type(force_str(s)), str) - def test_force_text_DjangoUnicodeDecodeError(self): + def test_force_str_DjangoUnicodeDecodeError(self): msg = ( "'utf-8' codec can't decode byte 0xff in position 0: invalid " "start byte. You passed in b'\\xff' (<class 'bytes'>)" ) with self.assertRaisesMessage(DjangoUnicodeDecodeError, msg): - force_text(b'\xff') + force_str(b'\xff') def test_force_bytes_exception(self): """ @@ -75,16 +75,16 @@ class TestEncodingUtils(SimpleTestCase): self.assertEqual(smart_bytes(1), b'1') self.assertEqual(smart_bytes('foo'), b'foo') - def test_smart_text(self): + def test_smart_str(self): class Test: def __str__(self): return 'ŠĐĆŽćžšđ' lazy_func = gettext_lazy('x') - self.assertIs(smart_text(lazy_func), lazy_func) - self.assertEqual(smart_text(Test()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111') - self.assertEqual(smart_text(1), '1') - self.assertEqual(smart_text('foo'), 'foo') + self.assertIs(smart_str(lazy_func), lazy_func) + self.assertEqual(smart_str(Test()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111') + self.assertEqual(smart_str(1), '1') + self.assertEqual(smart_str('foo'), 'foo') def test_get_default_encoding(self): with mock.patch('locale.getdefaultlocale', side_effect=Exception): |
