diff --git a/django/utils/functional.py b/django/utils/functional.py
index 1b5200c..773214d 100644
a
|
b
|
class SimpleLazyObject(LazyObject):
|
302 | 302 | def __reduce__(self): |
303 | 303 | return (self.__newobj__, (self.__class__,), self.__getstate__()) |
304 | 304 | |
| 305 | def __repr__(self): |
| 306 | if self._wrapped is empty: |
| 307 | repr_attr = self._setupfunc |
| 308 | else: |
| 309 | repr_attr = self._wrapped |
| 310 | return '<SimpleLazyObject: %r>' % repr_attr |
| 311 | |
305 | 312 | # Need to pretend to be the wrapped class, for the sake of objects that care |
306 | 313 | # about this (especially in equality tests) |
307 | 314 | __class__ = property(new_method_proxy(operator.attrgetter("__class__"))) |
diff --git a/tests/regressiontests/utils/simplelazyobject.py b/tests/regressiontests/utils/simplelazyobject.py
index 3f81e8f..e0d5d70 100644
a
|
b
|
class TestUtilsSimpleLazyObject(TestCase):
|
59 | 59 | hash(SimpleLazyObject(complex_object))) |
60 | 60 | |
61 | 61 | def test_repr(self): |
62 | | # For debugging, it will really confuse things if there is no clue that |
63 | | # SimpleLazyObject is actually a proxy object. So we don't |
64 | | # proxy __repr__ |
65 | | self.assertTrue("SimpleLazyObject" in repr(SimpleLazyObject(complex_object))) |
| 62 | # First, for an unevaluated SimpleLazyObject |
| 63 | x = SimpleLazyObject(complex_object) |
| 64 | # __repr__ contains __repr__ of setup function and does not evaluate |
| 65 | # the SimpleLazyObject |
| 66 | self.assertEqual("<SimpleLazyObject: %r>" % complex_object, repr(x)) |
| 67 | self.assertEqual(empty, x._wrapped) |
| 68 | |
| 69 | # Second, for an evaluated SimpleLazyObject |
| 70 | name = x.name # evaluate |
| 71 | # __repr__ contains __repr__ of wrapped object |
| 72 | self.assertEqual("<SimpleLazyObject: %r>" % complex_object(), repr(x)) |
66 | 73 | |
67 | 74 | def test_bytes(self): |
68 | 75 | self.assertEqual(b"I am _ComplexObject('joe')", |