diff options
Diffstat (limited to 'tests/testhelpers.py')
-rw-r--r-- | tests/testhelpers.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/testhelpers.py b/tests/testhelpers.py index aa59e99..b3b31ac 100644 --- a/tests/testhelpers.py +++ b/tests/testhelpers.py @@ -393,6 +393,20 @@ class SpecSignatureTest(unittest2.TestCase): m = create_autospec(Foo, a='3') self.assertEqual(m.a, '3') + @unittest2.skipUnless(inPy3k, "Keyword only arguments Python 3 specific") + def test_create_autospec_keyword_only_arguments(self): + func_def = "def foo(a, *, b=None):\n pass\n" + namespace = {} + exec (func_def, namespace) + foo = namespace['foo'] + + m = create_autospec(foo) + m(1) + m.assert_called_with(1) + self.assertRaises(TypeError, m, 1, 2) + + m(2, b=3) + m.assert_called_with(2, b=3) def test_function_as_instance_attribute(self): obj = SomeClass() |