I持ってあざけり次のコードtest_A.py MyClass.MyMethodなど:私は、しかしnosetestsの複数のテストで既存のコードを実行した後で、なぜ嘲笑が有効なのですか?
Class test_B(MockerTestCase):
def setUp(self):
pass
def test_me(self):
#Do something about MyClass.method
def tearDown(self):
pass
:私もモックMyClass.MyMethodなどをしない別のコードtest_B.pyを持って
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()
"nosetests test_A.py test_B.py"を実行すると、test_A.pyをテストした後にtest_B.pyと入力したように見えますが、MyClass.mymethodは依然としてモックアップされています。なぜ、どのように回避するかわからない。ありがとう!
ライブラリをからかっあなたはここで使用していますか?それは[mocker](http://labix.org/mocker)か[Mock](http://www.voidspace.org.uk/python/mock/)なのでしょうか? – srgerg
from unittestインポートメイン mockerからインポートMocker、MockerTestCase –