summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_lazyobject.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py
index 0ff15469d4..161c9dbcec 100644
--- a/tests/utils_tests/test_lazyobject.py
+++ b/tests/utils_tests/test_lazyobject.py
@@ -32,6 +32,28 @@ class LazyObjectTestCase(TestCase):
return AdHocLazyObject()
+ def test_getattribute(self):
+ """
+ Proxy methods don't exist on wrapped objects unless they're set.
+ """
+ attrs = [
+ "__getitem__",
+ "__setitem__",
+ "__delitem__",
+ "__iter__",
+ "__len__",
+ "__contains__",
+ ]
+ foo = Foo()
+ obj = self.lazy_wrap(foo)
+ for attr in attrs:
+ with self.subTest(attr):
+ self.assertFalse(hasattr(obj, attr))
+ setattr(foo, attr, attr)
+ obj_with_attr = self.lazy_wrap(foo)
+ self.assertTrue(hasattr(obj_with_attr, attr))
+ self.assertEqual(getattr(obj_with_attr, attr), attr)
+
def test_getattr(self):
obj = self.lazy_wrap(Foo())
self.assertEqual(obj.foo, "bar")