summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorPreston Holmes <preston@ptone.com>2013-03-06 16:00:05 -0800
committerPreston Holmes <preston@ptone.com>2013-03-06 16:13:12 -0800
commit0ea5bf88dddd7fbdef7fe8d00162c9753565f5c0 (patch)
tree18c72b0c276cbbd2f19b0911da113b3c91222d46 /tests/utils_tests
parentc8e3a23d0f6d6683c7d5d4f4107b0c716b879cf0 (diff)
Fixed #19543 -- implemented SimpleLazyObject.__repr__
Thanks to Florian Hahn for the patch
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/simplelazyobject.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/utils_tests/simplelazyobject.py b/tests/utils_tests/simplelazyobject.py
index 3f81e8f608..dd52857c03 100644
--- a/tests/utils_tests/simplelazyobject.py
+++ b/tests/utils_tests/simplelazyobject.py
@@ -59,10 +59,18 @@ class TestUtilsSimpleLazyObject(TestCase):
hash(SimpleLazyObject(complex_object)))
def test_repr(self):
- # For debugging, it will really confuse things if there is no clue that
- # SimpleLazyObject is actually a proxy object. So we don't
- # proxy __repr__
- self.assertTrue("SimpleLazyObject" in repr(SimpleLazyObject(complex_object)))
+ # First, for an unevaluated SimpleLazyObject
+ x = SimpleLazyObject(complex_object)
+ # __repr__ contains __repr__ of setup function and does not evaluate
+ # the SimpleLazyObject
+ self.assertEqual("<SimpleLazyObject: %r>" % complex_object, repr(x))
+ self.assertEqual(empty, x._wrapped)
+
+ # Second, for an evaluated SimpleLazyObject
+ name = x.name # evaluate
+ self.assertTrue(isinstance(x._wrapped, _ComplexObject))
+ # __repr__ contains __repr__ of wrapped object
+ self.assertEqual("<SimpleLazyObject: %r>" % x._wrapped, repr(x))
def test_bytes(self):
self.assertEqual(b"I am _ComplexObject('joe')",