File tree
3 files changed
+12
-1
lines changed- Lib/unittest
- test/testmock
- Misc/NEWS.d/next/Library
3 files changed
+12
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
406 | 406 |
| |
407 | 407 |
| |
408 | 408 |
| |
409 |
| - | |
| 409 | + | |
410 | 410 |
| |
411 | 411 |
| |
412 | 412 |
| |
|
Lines changed: 10 additions & 0 deletions
@@ -2156,6 +2156,16 @@ def trace(frame, event, arg): # pragma: no cover
2156
2156
obj = mock(spec=Something)
2157
2157
self.assertIsInstance(obj, Something)
2158
2158
2159
+ def test_bool_not_called_when_passing_spec_arg(self):
2160
+ class Something:
2161
+ def __init__(self):
2162
+ self.obj_with_bool_func = unittest.mock.MagicMock()
2163
+
2164
+ obj = Something()
2165
+ with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True): pass
2166
+
2167
+ self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)
2168
+
2159
2169
2160
2170
if __name__ == '__main__':
2161
2171
unittest.main()
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + |
0 commit comments