mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
unittest.mock: a mock created by patch with a spec as the list argument will be callable if __call__ is in the spec
This commit is contained in:
parent
87b3caf873
commit
e58a562d93
2 changed files with 28 additions and 1 deletions
|
@ -1742,6 +1742,26 @@ class PatchTest(unittest.TestCase):
|
|||
p.stop()
|
||||
|
||||
|
||||
def test_callable_spec_as_list(self):
|
||||
spec = ('__call__',)
|
||||
p = patch(MODNAME, spec=spec)
|
||||
m = p.start()
|
||||
try:
|
||||
self.assertTrue(callable(m))
|
||||
finally:
|
||||
p.stop()
|
||||
|
||||
|
||||
def test_not_callable_spec_as_list(self):
|
||||
spec = ('foo', 'bar')
|
||||
p = patch(MODNAME, spec=spec)
|
||||
m = p.start()
|
||||
try:
|
||||
self.assertFalse(callable(m))
|
||||
finally:
|
||||
p.stop()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue