MCPcopy Create free account
hub / github.com/python/cpython / test_dunder_call

Method test_dunder_call

Lib/test/test_unittest/testmock/testhelpers.py:360–378  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

358 self.assertEqual(_Call((('bar', 'barz'), {'hello': 'world'}),)[0], '')
359
360 def test_dunder_call(self):
361 m = MagicMock()
362 m().foo()['bar']()
363 self.assertEqual(
364 m.mock_calls,
365 [call(), call().foo(), call().foo().__getitem__('bar'), call().foo().__getitem__()()]
366 )
367 m = MagicMock()
368 m().foo()['bar'] = 1
369 self.assertEqual(
370 m.mock_calls,
371 [call(), call().foo(), call().foo().__setitem__('bar', 1)]
372 )
373 m = MagicMock()
374 iter(m().foo())
375 self.assertEqual(
376 m.mock_calls,
377 [call(), call().foo(), call().foo().__iter__()]
378 )
379
380
381class SpecSignatureTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 8

MagicMockClass · 0.90
mFunction · 0.50
callFunction · 0.50
fooMethod · 0.45
assertEqualMethod · 0.45
__getitem__Method · 0.45
__setitem__Method · 0.45
__iter__Method · 0.45

Tested by

no test coverage detected