mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Remove more Python 2 compatibility cruft from unittest.mock
This commit is contained in:
parent
e7c8fdee18
commit
a74b3aa0cc
2 changed files with 6 additions and 25 deletions
|
|
@ -107,19 +107,9 @@ class TestCallable(unittest.TestCase):
|
|||
class Multi(SomeClass, Sub):
|
||||
pass
|
||||
|
||||
class OldStyle:
|
||||
def __call__(self):
|
||||
pass
|
||||
|
||||
class OldStyleSub(OldStyle):
|
||||
pass
|
||||
|
||||
for arg in 'spec', 'spec_set':
|
||||
for Klass in CallableX, Sub, Multi, OldStyle, OldStyleSub:
|
||||
patcher = patch('%s.X' % __name__, **{arg: Klass})
|
||||
mock = patcher.start()
|
||||
|
||||
try:
|
||||
for Klass in CallableX, Sub, Multi:
|
||||
with patch('%s.X' % __name__, **{arg: Klass}) as mock:
|
||||
instance = mock()
|
||||
mock.assert_called_once_with()
|
||||
|
||||
|
|
@ -136,8 +126,6 @@ class TestCallable(unittest.TestCase):
|
|||
result.assert_called_once_with(3, 2, 1)
|
||||
result.foo(3, 2, 1)
|
||||
result.foo.assert_called_once_with(3, 2, 1)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
|
||||
def test_create_autopsec(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue