From 2bc0fc8413c02a7faf3a116fe875d76bc3403117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Tue, 5 Mar 2013 00:36:08 +0100 Subject: Cleanup argument extraction in PostGenMethod (See #36). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides a consistent behaviour for extracting arguments to a PostGenerationMethodCall. Signed-off-by: Raphaƫl Barrois --- tests/test_declarations.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests/test_declarations.py') 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): -- cgit v1.2.3