From 8879108f5595099785565cae35938a356bbbeced Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Fri, 9 Mar 2012 22:06:26 +0100 Subject: Add a couple of tests for scope bleeding with InfiniteIterator and list comprehensions (See #6). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- tests/test_using.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_using.py b/tests/test_using.py index 41b34ea..7f9f09c 100644 --- a/tests/test_using.py +++ b/tests/test_using.py @@ -780,6 +780,25 @@ class IteratorTestCase(unittest.TestCase): for i, obj in enumerate(objs): self.assertEqual(i % 5, obj.one) + def test_infinite_iterator_list_comprehension(self): + class TestObjectFactory(factory.Factory): + one = factory.InfiniteIterator([j * 3 for j in xrange(5)]) + + # Scope bleeding: j will end up in TestObjectFactory's scope. + + self.assertRaises(TypeError, TestObjectFactory.build) + + def test_infinite_iterator_list_comprehension_protected(self): + class TestObjectFactory(factory.Factory): + one = factory.InfiniteIterator([_j * 3 for _j in xrange(5)]) + + # Scope bleeding : _j will end up in TestObjectFactory's scope. + # But factory_boy ignores it, as a protected variable. + objs = TestObjectFactory.build_batch(20) + + for i, obj in enumerate(objs): + self.assertEqual(3 * (i % 5), obj.one) + def test_iterator_decorator(self): class TestObjectFactory(factory.Factory): @factory.iterator -- cgit v1.2.3 From 0f4e9d32a68ed6757f0e3a9216d3bbb4cf2f1280 Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Fri, 9 Mar 2012 22:22:05 +0100 Subject: Add MANIFEST.in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- MANIFEST.in | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..382d9bf --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README +include docs/Makefile +recursive-include docs *.py *.rst +prune docs/_build -- cgit v1.2.3 From f061672eed5fb5849d4f4141ba82963ba6913ebc Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Fri, 9 Mar 2012 22:32:50 +0100 Subject: Add MANIFEST.in entries for docs and tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- MANIFEST.in | 2 ++ docs/_static/.keep_dir | 0 2 files changed, 2 insertions(+) create mode 100644 docs/_static/.keep_dir diff --git a/MANIFEST.in b/MANIFEST.in index 382d9bf..3912fee 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,6 @@ include README include docs/Makefile recursive-include docs *.py *.rst +include docs/_static/.keep_dir prune docs/_build +recursive-include tests *.py diff --git a/docs/_static/.keep_dir b/docs/_static/.keep_dir new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From 84019217057d1752fba021b2bfe940af5636977d Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Fri, 9 Mar 2012 22:33:31 +0100 Subject: Version bump, for packaging purposes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ae0a0d4..b3ce56f 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from distutils.core import setup from distutils import cmd # Remember to change in factory/__init__.py as well! -VERSION = '1.1.2' +VERSION = '1.1.3' class test(cmd.Command): -- cgit v1.2.3