mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #24836 -- Made force_text() resolve lazy objects.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user