我有以下代码 test_A.py 模拟 MyClass.mymethod:
from unittest import main
from mocker import Mocker, MockerTestCase
Class test_A(MockerTestCase):
def setUp(self):
self.m=Mock()
MyClass.mymethod = self.m.mock()
self.m.result(None)
self.m.count(0,None)
self.m.replay()
def test_me(self):
#Do something about MyClass.method
def tearDown(self):
self.m.restore()
self.m.verify()
我还有另一个代码 test_B.py,它不模拟 MyClass.mymethod:
Class test_B(MockerTestCase):
def setUp(self):
pass
def test_me(self):
#Do something about MyClass.method
def tearDown(self):
pass
但是,当我执行“nosetests test_A.py test_B.py”时,看起来在测试 test_A.py 并进入 test_B.py 之后,MyClass.mymethod 仍然是模拟的。不知道为什么以及如何解决它。谢谢!