diff options
| author | Rik <gitaarik@gmail.com> | 2015-03-07 15:51:17 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2015-03-08 15:42:23 +0100 |
| commit | a5b225084f69e27b78fab0f2954fa9520656976e (patch) | |
| tree | d23da69f04b9cbe97b3511063d83075ea1a33ae8 /tests/utils_tests/test_lazyobject.py | |
| parent | 888c9b6429a44824078a49fb1ebacf2e950cd887 (diff) | |
Fixed #23838 -- added missing `__iter__` to LazyObject
Diffstat (limited to 'tests/utils_tests/test_lazyobject.py')
| -rw-r--r-- | tests/utils_tests/test_lazyobject.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py index a80f0a2c95..ce2b66f3cb 100644 --- a/tests/utils_tests/test_lazyobject.py +++ b/tests/utils_tests/test_lazyobject.py @@ -165,11 +165,22 @@ class LazyObjectTestCase(TestCase): del obj_dict['f'] def test_iter(self): - # LazyObjects don't actually implements __iter__ but you can still - # iterate over them because they implement __getitem__ - obj = self.lazy_wrap([1, 2, 3]) - for expected, actual in zip([1, 2, 3], obj): - self.assertEqual(expected, actual) + # Tests whether an object's custom `__iter__` method is being + # used when iterating over it. + + class IterObject(object): + + def __init__(self, values): + self.values = values + + def __iter__(self): + return iter(self.values) + + original_list = ['test', '123'] + self.assertEqual( + list(self.lazy_wrap(IterObject(original_list))), + original_list + ) def test_pickle(self): # See ticket #16563 |
