MCPcopy Index your code
hub / github.com/python/cpython / test_constructor

Method test_constructor

Lib/test/test_unittest/testmock/testmock.py:70–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

68
69
70 def test_constructor(self):
71 mock = Mock()
72
73 self.assertFalse(mock.called, "called not initialised correctly")
74 self.assertEqual(mock.call_count, 0,
75 "call_count not initialised correctly")
76 self.assertTrue(is_instance(mock.return_value, Mock),
77 "return_value not initialised correctly")
78
79 self.assertEqual(mock.call_args, None,
80 "call_args not initialised correctly")
81 self.assertEqual(mock.call_args_list, [],
82 "call_args_list not initialised correctly")
83 self.assertEqual(mock.method_calls, [],
84 "method_calls not initialised correctly")
85
86 # Can't use hasattr for this test as it always returns True on a mock
87 self.assertNotIn('_items', mock.__dict__,
88 "default mock should not have '_items' attribute")
89
90 self.assertIsNone(mock._mock_parent,
91 "parent not initialised correctly")
92 self.assertIsNone(mock._mock_methods,
93 "methods not initialised correctly")
94 self.assertEqual(mock._mock_children, {},
95 "children not initialised incorrectly")
96
97
98 def test_return_value_in_constructor(self):

Callers

nothing calls this directly

Calls 7

MockClass · 0.90
is_instanceFunction · 0.90
assertFalseMethod · 0.80
assertTrueMethod · 0.80
assertNotInMethod · 0.80
assertIsNoneMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected