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

Method test_manager_mock

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

Source from the content-addressed store, hash-verified

2009
2010
2011 def test_manager_mock(self):
2012 class Foo(object):
2013 one = 'one'
2014 two = 'two'
2015 manager = Mock()
2016 p1 = patch.object(Foo, 'one')
2017 p2 = patch.object(Foo, 'two')
2018
2019 mock_one = p1.start()
2020 self.addCleanup(p1.stop)
2021 mock_two = p2.start()
2022 self.addCleanup(p2.stop)
2023
2024 manager.attach_mock(mock_one, 'one')
2025 manager.attach_mock(mock_two, 'two')
2026
2027 Foo.two()
2028 Foo.one()
2029
2030 self.assertEqual(manager.mock_calls, [call.two(), call.one()])
2031
2032
2033 def test_magic_methods_mock_calls(self):

Callers

nothing calls this directly

Calls 7

MockClass · 0.90
addCleanupMethod · 0.80
attach_mockMethod · 0.80
startMethod · 0.45
twoMethod · 0.45
oneMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected