mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #24781 -- Fixed repr() for lazy objects.
This commit is contained in:
parent
2f9c4e2b6f
commit
ffd18732f3
2 changed files with 18 additions and 0 deletions
|
@ -130,3 +130,18 @@ class FunctionalTestCase(unittest.TestCase):
|
|||
|
||||
self.assertEqual(lazy_a(), lazy_b())
|
||||
self.assertNotEqual(lazy_b(), lazy_c())
|
||||
|
||||
def test_lazy_repr_text(self):
|
||||
original_object = 'Lazy translation text'
|
||||
lazy_obj = lazy(lambda: original_object, six.text_type)
|
||||
self.assertEquals(repr(original_object), repr(lazy_obj()))
|
||||
|
||||
def test_lazy_repr_int(self):
|
||||
original_object = 15
|
||||
lazy_obj = lazy(lambda: original_object, int)
|
||||
self.assertEquals(repr(original_object), repr(lazy_obj()))
|
||||
|
||||
def test_lazy_repr_bytes(self):
|
||||
original_object = b'J\xc3\xbcst a str\xc3\xadng'
|
||||
lazy_obj = lazy(lambda: original_object, bytes)
|
||||
self.assertEquals(repr(original_object), repr(lazy_obj()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue