Skip to content

Commit 71c4f0c

Browse files
idanw206Idan Weiss
authored andcommitted
Added test for unexpected call of when passing spec_arg in mock module
1 parent d3b40aa commit 71c4f0c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/unittest/test/testmock/testmock.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,16 @@ def trace(frame, event, arg): # pragma: no cover
21642164
for mock in mocks:
21652165
obj = mock(spec=Something)
21662166
self.assertIsInstance(obj, Something)
2167+
2168+
def test_bool_not_called_when_passing_spec_arg(self):
2169+
class Something:
2170+
def __init__(self):
2171+
self.obj_with_bool_func = unittest.mock.MagicMock()
2172+
2173+
obj = Something()
2174+
with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True):
2175+
pass
2176+
self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)
21672177

21682178

21692179
if __name__ == '__main__':

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy