diff options
| author | Tim Graham <timograham@gmail.com> | 2015-05-26 16:46:13 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-05-27 09:48:53 -0400 |
| commit | 70be31bba7f8658f17235e33862319780c3dfad1 (patch) | |
| tree | 6c4407ecbd419598500ce0f70d7b98339353fc7d /tests/utils_tests/test_encoding.py | |
| parent | 10945ebeb84157a284ad96f453ee13305a9d8a94 (diff) | |
Fixed #24836 -- Made force_text() resolve lazy objects.
Diffstat (limited to 'tests/utils_tests/test_encoding.py')
| -rw-r--r-- | tests/utils_tests/test_encoding.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py index 81024bdf12..9527f29dcf 100644 --- a/tests/utils_tests/test_encoding.py +++ b/tests/utils_tests/test_encoding.py @@ -9,6 +9,7 @@ from django.utils.encoding import ( escape_uri_path, filepath_to_uri, force_bytes, force_text, iri_to_uri, smart_text, uri_to_iri, ) +from django.utils.functional import SimpleLazyObject from django.utils.http import urlquote_plus @@ -28,6 +29,10 @@ class TestEncodingUtils(unittest.TestCase): exception = TypeError if six.PY3 else UnicodeError self.assertRaises(exception, force_text, MyString()) + def test_force_text_lazy(self): + s = SimpleLazyObject(lambda: 'x') + self.assertTrue(issubclass(type(force_text(s)), six.text_type)) + def test_force_bytes_exception(self): """ Test that force_bytes knows how to convert to bytes an exception |
