diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-11 22:36:30 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-11 22:36:30 +0100 |
commit | 60f0969406bd349a8a8b88fcaec819fa5c0525cb (patch) | |
tree | 6cf85cd478335d196d87bf4051986e007abc05a4 /tests | |
parent | 16e1a65f5b93615d946b74e3fb4d0b61c99ae0d2 (diff) | |
download | factory-boy-60f0969406bd349a8a8b88fcaec819fa5c0525cb.tar factory-boy-60f0969406bd349a8a8b88fcaec819fa5c0525cb.tar.gz |
Remove extract_prefix from post-generation hooks.
Magic abuse is bad.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_declarations.py | 85 | ||||
-rw-r--r-- | tests/test_using.py | 19 |
2 files changed, 0 insertions, 104 deletions
diff --git a/tests/test_declarations.py b/tests/test_declarations.py index ceadafa..b7ae344 100644 --- a/tests/test_declarations.py +++ b/tests/test_declarations.py @@ -122,26 +122,6 @@ class PostGenerationDeclarationTestCase(unittest.TestCase): self.assertEqual(extracted, 13) self.assertEqual(kwargs, {'bar': 42}) - @tools.disable_warnings - def test_extract_with_prefix(self): - decl = declarations.PostGenerationDeclaration(extract_prefix='blah') - - extracted, kwargs = decl.extract('foo', - {'foo': 13, 'foo__bar': 42, 'blah': 42, 'blah__baz': 1}) - self.assertEqual(extracted, 42) - self.assertEqual(kwargs, {'baz': 1}) - - def test_extract_prefix_deprecated(self): - with warnings.catch_warnings(record=True) as w: - __warningregistry__.clear() - - warnings.simplefilter('always') - declarations.PostGenerationDeclaration(extract_prefix='blah') - - self.assertEqual(1, len(w)) - self.assertIn('extract_prefix', str(w[0].message)) - self.assertIn('deprecated', str(w[0].message)) - def test_decorator_simple(self): call_params = [] @declarations.post_generation @@ -160,71 +140,6 @@ class PostGenerationDeclarationTestCase(unittest.TestCase): self.assertEqual((None, False, 13), call_params[0]) self.assertEqual({'bar': 42}, call_params[1]) - @tools.disable_warnings - def test_decorator_call_no_prefix(self): - call_params = [] - @declarations.post_generation() - def foo(*args, **kwargs): - call_params.append(args) - call_params.append(kwargs) - - extracted, kwargs = foo.extract('foo', - {'foo': 13, 'foo__bar': 42, 'blah': 42, 'blah__baz': 1}) - self.assertEqual(13, extracted) - self.assertEqual({'bar': 42}, kwargs) - - # No value returned. - foo.call(None, False, extracted, **kwargs) - self.assertEqual(2, len(call_params)) - self.assertEqual((None, False, 13), call_params[0]) - self.assertEqual({'bar': 42}, call_params[1]) - - @tools.disable_warnings - def test_decorator_extract_prefix(self): - call_params = [] - @declarations.post_generation(extract_prefix='blah') - def foo(*args, **kwargs): - call_params.append(args) - call_params.append(kwargs) - - extracted, kwargs = foo.extract('foo', - {'foo': 13, 'foo__bar': 42, 'blah': 42, 'blah__baz': 1}) - self.assertEqual(42, extracted) - self.assertEqual({'baz': 1}, kwargs) - - # No value returned. - foo.call(None, False, extracted, **kwargs) - self.assertEqual(2, len(call_params)) - self.assertEqual((None, False, 42), call_params[0]) - self.assertEqual({'baz': 1}, call_params[1]) - - def test_decorator_call_no_prefix_deprecated(self): - with warnings.catch_warnings(record=True) as w: - __warningregistry__.clear() - - warnings.simplefilter('always') - @declarations.post_generation() - def foo(*args, **kwargs): - pass - - self.assertEqual(1, len(w)) - self.assertIn('post_generation', str(w[0].message)) - self.assertIn('deprecated', str(w[0].message)) - - def test_decorator_call_with_prefix_deprecated(self): - with warnings.catch_warnings(record=True) as w: - __warningregistry__.clear() - - warnings.simplefilter('always') - @declarations.post_generation(extract_prefix='blah') - def foo(*args, **kwargs): - pass - - # 2 warnings: decorator with brackets, and extract_prefix. - self.assertEqual(2, len(w)) - self.assertIn('post_generation', str(w[0].message)) - self.assertIn('deprecated', str(w[0].message)) - class SubFactoryTestCase(unittest.TestCase): diff --git a/tests/test_using.py b/tests/test_using.py index b617668..a0b0db7 100644 --- a/tests/test_using.py +++ b/tests/test_using.py @@ -1218,25 +1218,6 @@ class PostGenerationTestCase(unittest.TestCase): self.assertFalse(obj.create) self.assertEqual({'incr_one': 42}, obj.results) - @tools.disable_warnings - def test_post_generation_calling(self): - class TestObjectFactory(factory.Factory): - FACTORY_FOR = TestObject - - one = 1 - - @factory.post_generation() - def incr_one(self, _create, _increment): - self.one += 1 - - obj = TestObjectFactory.build() - self.assertEqual(2, obj.one) - self.assertFalse(hasattr(obj, 'incr_one')) - - obj = TestObjectFactory.build(one=2) - self.assertEqual(3, obj.one) - self.assertFalse(hasattr(obj, 'incr_one')) - def test_post_generation_extraction(self): class TestObjectFactory(factory.Factory): FACTORY_FOR = TestObject |