Any way to reset a mocked method to its original state? - Python Mock - mock 1.0b1
问题 I have the following simplified class I'm mocking: class myClass(object): @staticmethod def A(): #... def check(self): #code... value = self.A() #more code... In my first test I mock only the method A from django.test import TestCase from mock import MagicMock import myClass class FirstTest(TestCase): def setUp(self): myClass.A = MagicMock(return_value = 'CPU') def test(self): #some tests myClassObj = myClass() myClassObj.check() Whereas in my second test I mock the entire check method: from