Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added test for unexpected call of when passing spec_arg in mock module
  • Loading branch information
idanw206 authored and Idan Weiss committed Dec 6, 2020
commit 71c4f0cb7c377664bdff7ece8a5c8c67c7411dc0
10 changes: 10 additions & 0 deletions Lib/unittest/test/testmock/testmock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,16 @@ def trace(frame, event, arg): # pragma: no cover
for mock in mocks:
obj = mock(spec=Something)
self.assertIsInstance(obj, Something)

def test_bool_not_called_when_passing_spec_arg(self):
class Something:
def __init__(self):
self.obj_with_bool_func = unittest.mock.MagicMock()

obj = Something()
with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True):
pass
self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)


if __name__ == '__main__':
Expand Down