diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-05 00:36:08 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-05 00:39:25 +0100 |
commit | 2bc0fc8413c02a7faf3a116fe875d76bc3403117 (patch) | |
tree | 4dc134b66bee6bf280b9d4f31766c8b3efef5117 /tests | |
parent | 3c011a3c6e97e40410ad88a734605759fb247301 (diff) | |
download | factory-boy-2bc0fc8413c02a7faf3a116fe875d76bc3403117.tar factory-boy-2bc0fc8413c02a7faf3a116fe875d76bc3403117.tar.gz |
Cleanup argument extraction in PostGenMethod (See #36).
This provides a consistent behaviour for extracting arguments to
a PostGenerationMethodCall.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_declarations.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/test_declarations.py b/tests/test_declarations.py index 93e11d0..b11a4a8 100644 --- a/tests/test_declarations.py +++ b/tests/test_declarations.py @@ -306,13 +306,13 @@ class PostGenerationMethodCallTestCase(unittest.TestCase): def test_call_with_method_args(self): decl = declarations.PostGenerationMethodCall( - 'method', None, 'data') + 'method', 'data') decl.call(self.obj, False) self.obj.method.assert_called_once_with('data') def test_call_with_passed_extracted_string(self): decl = declarations.PostGenerationMethodCall( - 'method', None) + 'method') decl.call(self.obj, False, 'data') self.obj.method.assert_called_once_with('data') @@ -324,11 +324,11 @@ class PostGenerationMethodCallTestCase(unittest.TestCase): def test_call_with_passed_extracted_iterable(self): decl = declarations.PostGenerationMethodCall('method') decl.call(self.obj, False, (1, 2, 3)) - self.obj.method.assert_called_once_with(1, 2, 3) + self.obj.method.assert_called_once_with((1, 2, 3)) def test_call_with_method_kwargs(self): decl = declarations.PostGenerationMethodCall( - 'method', None, data='data') + 'method', data='data') decl.call(self.obj, False) self.obj.method.assert_called_once_with(data='data') @@ -337,7 +337,23 @@ class PostGenerationMethodCallTestCase(unittest.TestCase): decl.call(self.obj, False, data='other') self.obj.method.assert_called_once_with(data='other') + def test_multi_call_with_multi_method_args(self): + decl = declarations.PostGenerationMethodCall( + 'method', 'arg1', 'arg2') + decl.call(self.obj, False) + self.obj.method.assert_called_once_with('arg1', 'arg2') + def test_multi_call_with_passed_multiple_args(self): + decl = declarations.PostGenerationMethodCall( + 'method', 'arg1', 'arg2') + decl.call(self.obj, False, ('param1', 'param2', 'param3')) + self.obj.method.assert_called_once_with('param1', 'param2', 'param3') + + def test_multi_call_with_passed_tuple(self): + decl = declarations.PostGenerationMethodCall( + 'method', 'arg1', 'arg2') + decl.call(self.obj, False, (('param1', 'param2'),)) + self.obj.method.assert_called_once_with(('param1', 'param2')) class CircularSubFactoryTestCase(unittest.TestCase): |