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

Method _test2

Lib/test/test_unittest/testmock/testpatch.py:954–981  ·  view source on GitHub ↗
(mock)

Source from the content-addressed store, hash-verified

952 self.assertRaises(TypeError, mock)
953
954 def _test2(mock):
955 mock.f(1)
956 mock.f.assert_called_with(1)
957 self.assertRaises(TypeError, mock.f)
958
959 mock.g()
960 mock.g.assert_called_with()
961 self.assertRaises(TypeError, mock.g, 1)
962
963 self.assertRaises(AttributeError, getattr, mock, 'h')
964
965 mock.foo.lower()
966 mock.foo.lower.assert_called_with()
967 self.assertRaises(AttributeError, getattr, mock.foo, 'bar')
968
969 mock.Bar()
970 mock.Bar.assert_called_with()
971
972 mock.Bar.a()
973 mock.Bar.a.assert_called_with()
974 self.assertRaises(TypeError, mock.Bar.a, 1)
975
976 mock.Bar().a()
977 mock.Bar().a.assert_called_with()
978 self.assertRaises(TypeError, mock.Bar().a, 1)
979
980 self.assertRaises(AttributeError, getattr, mock.Bar, 'b')
981 self.assertRaises(AttributeError, getattr, mock.Bar(), 'b')
982
983 def function(mock):
984 _test(mock)

Callers

nothing calls this directly

Calls 6

assert_called_withMethod · 0.80
fMethod · 0.45
assertRaisesMethod · 0.45
gMethod · 0.45
lowerMethod · 0.45
aMethod · 0.45

Tested by

no test coverage detected