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

Method test_arg_lists

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

Source from the content-addressed store, hash-verified

1353
1354
1355 def test_arg_lists(self):
1356 mocks = [
1357 Mock(),
1358 MagicMock(),
1359 NonCallableMock(),
1360 NonCallableMagicMock()
1361 ]
1362
1363 def assert_attrs(mock):
1364 names = 'call_args_list', 'method_calls', 'mock_calls'
1365 for name in names:
1366 attr = getattr(mock, name)
1367 self.assertIsInstance(attr, _CallList)
1368 self.assertIsInstance(attr, list)
1369 self.assertEqual(attr, [])
1370
1371 for mock in mocks:
1372 assert_attrs(mock)
1373
1374 if callable(mock):
1375 mock()
1376 mock(1, 2)
1377 mock(a=3)
1378
1379 mock.reset_mock()
1380 assert_attrs(mock)
1381
1382 mock.foo()
1383 mock.foo.bar(1, a=3)
1384 mock.foo(1).bar().baz(3)
1385
1386 mock.reset_mock()
1387 assert_attrs(mock)
1388
1389
1390 def test_call_args_two_tuple(self):

Callers

nothing calls this directly

Calls 8

MockClass · 0.90
MagicMockClass · 0.90
NonCallableMockClass · 0.90
reset_mockMethod · 0.45
fooMethod · 0.45
barMethod · 0.45
bazMethod · 0.45

Tested by

no test coverage detected