mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
Closes issue 14634. unittest.mock.create_autospec now supports keyword only arguments.
This commit is contained in:
parent
2cd48738ba
commit
3af125a4aa
3 changed files with 31 additions and 8 deletions
|
@ -367,7 +367,7 @@ class SpecSignatureTest(unittest.TestCase):
|
|||
|
||||
|
||||
def test_create_autospec_unbound_methods(self):
|
||||
# see issue 128
|
||||
# see mock issue 128
|
||||
# this is expected to fail until the issue is fixed
|
||||
return
|
||||
class Foo(object):
|
||||
|
@ -391,6 +391,19 @@ class SpecSignatureTest(unittest.TestCase):
|
|||
self.assertEqual(m.a, '3')
|
||||
|
||||
|
||||
def test_create_autospec_keyword_only_arguments(self):
|
||||
def foo(a, *, b=None):
|
||||
pass
|
||||
|
||||
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()
|
||||
def f(a):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue