diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-11 22:28:43 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-11 22:28:43 +0100 |
commit | de3a552eab032cb980a2fb78976fc3dc8cd5f1c8 (patch) | |
tree | 1eb5e3cbc27f5abd9c9d4b1729c152a1db97c3ee /tests | |
parent | e2ac08066fbc6b6412b713b42aba792c224067f5 (diff) | |
download | factory-boy-de3a552eab032cb980a2fb78976fc3dc8cd5f1c8.tar factory-boy-de3a552eab032cb980a2fb78976fc3dc8cd5f1c8.tar.gz |
Remove InfiniteIterator and infinite_iterator.
Use Iterator/iterator instead.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_using.py | 65 |
1 files changed, 4 insertions, 61 deletions
diff --git a/tests/test_using.py b/tests/test_using.py index 5287a6d..b617668 100644 --- a/tests/test_using.py +++ b/tests/test_using.py @@ -1137,50 +1137,24 @@ class IteratorTestCase(unittest.TestCase): for i, obj in enumerate(objs): self.assertEqual(i + 10, obj.one) - def test_infinite_iterator_deprecated(self): - with warnings.catch_warnings(record=True) as w: - __warningregistry__.clear() - - warnings.simplefilter('always') - class TestObjectFactory(factory.Factory): - FACTORY_FOR = TestObject - - foo = factory.InfiniteIterator(range(5)) - - self.assertEqual(1, len(w)) - self.assertIn('InfiniteIterator', str(w[0].message)) - self.assertIn('deprecated', str(w[0].message)) - - @tools.disable_warnings - def test_infinite_iterator(self): - class TestObjectFactory(factory.Factory): - FACTORY_FOR = TestObject - - one = factory.InfiniteIterator(range(5)) - - objs = TestObjectFactory.build_batch(20) - - for i, obj in enumerate(objs): - self.assertEqual(i % 5, obj.one) - @unittest.skipUnless(is_python2, "Scope bleeding fixed in Python3+") @tools.disable_warnings - def test_infinite_iterator_list_comprehension_scope_bleeding(self): + def test_iterator_list_comprehension_scope_bleeding(self): class TestObjectFactory(factory.Factory): FACTORY_FOR = TestObject - one = factory.InfiniteIterator([j * 3 for j in range(5)]) + one = factory.Iterator([j * 3 for j in range(5)]) # Scope bleeding: j will end up in TestObjectFactory's scope. self.assertRaises(TypeError, TestObjectFactory.build) @tools.disable_warnings - def test_infinite_iterator_list_comprehension_protected(self): + def test_iterator_list_comprehension_protected(self): class TestObjectFactory(factory.Factory): FACTORY_FOR = TestObject - one = factory.InfiniteIterator([_j * 3 for _j in range(5)]) + one = factory.Iterator([_j * 3 for _j in range(5)]) # Scope bleeding : _j will end up in TestObjectFactory's scope. # But factory_boy ignores it, as a protected variable. @@ -1203,37 +1177,6 @@ class IteratorTestCase(unittest.TestCase): for i, obj in enumerate(objs): self.assertEqual(i + 10, obj.one) - def test_infinite_iterator_decorator_deprecated(self): - with warnings.catch_warnings(record=True) as w: - __warningregistry__.clear() - - warnings.simplefilter('always') - class TestObjectFactory(factory.Factory): - FACTORY_FOR = TestObject - - @factory.infinite_iterator - def one(): - return range(5) - - self.assertEqual(1, len(w)) - self.assertIn('infinite_iterator', str(w[0].message)) - self.assertIn('deprecated', str(w[0].message)) - - @tools.disable_warnings - def test_infinite_iterator_decorator(self): - class TestObjectFactory(factory.Factory): - FACTORY_FOR = TestObject - - @factory.infinite_iterator - def one(): - for i in range(5): - yield i - - objs = TestObjectFactory.build_batch(20) - - for i, obj in enumerate(objs): - self.assertEqual(i % 5, obj.one) - class PostGenerationTestCase(unittest.TestCase): def test_post_generation(self): |