1>>> class ProductionClass:
2... def method(self):
3... self.something(1, 2, 3)
4... def something(self, a, b, c):
5... pass
6...
7>>> real = ProductionClass()
8>>> real.something = MagicMock()
9>>> real.method()
10>>> real.something.assert_called_once_with(1, 2, 3)
11
1>>> class ProductionClass:
2... def closer(self, something):
3... something.close()
4...
5
1>>> real = SomeClass()
2>>> real.method = MagicMock(name='method')
3>>> real.method(3, 4, 5, key='value')
4<MagicMock name='method()' id='...'>
5
1>>> real = ProductionClass()
2>>> mock = Mock()
3>>> real.closer(mock)
4>>> mock.close.assert_called_with()
5