summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2008-03-28 19:39:41 -0300
committerGustavo Niemeyer <gustavo@niemeyer.net>2008-03-28 19:39:41 -0300
commitf21dc94aa7733ebcf5503359c47c97beb458e094 (patch)
treef0fad86816853741eb45e1bc84c4ee7f63f53ee2
parentd7c9c348405704cb69e9658df28d6008c5b2df7e (diff)
downloadmocker-f21dc94aa7733ebcf5503359c47c97beb458e094.tar.gz
When cleaning up on MockerTestCase, use reset() rather than restore(),
so that the same test case instance may be run more than once (like Trial does).
-rw-r--r--mocker.py2
-rwxr-xr-xtest.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/mocker.py b/mocker.py
index 1e92f72..bca5160 100644
--- a/mocker.py
+++ b/mocker.py
@@ -149,7 +149,7 @@ class MockerTestCase(unittest.TestCase):
os.unlink(path)
elif os.path.isdir(path):
shutil.rmtree(path)
- self.mocker.restore()
+ self.mocker.reset()
for func, args, kwargs in self.__cleanup_funcs:
func(*args, **kwargs)
diff --git a/test.py b/test.py
index 173e51e..334407f 100755
--- a/test.py
+++ b/test.py
@@ -390,6 +390,17 @@ class MockerTestCaseTest(TestCase):
self.assertEquals(len(result.failures), 1)
self.assertTrue("BOOM!" in result.failures[0][1])
+ del calls[:]
+
+ result = unittest.TestResult()
+ # Running twice in the same instance (Trial does that).
+ test = MyTest("test_method")
+ test.run(result)
+ test.run(result)
+
+ self.assertEquals(calls, ["verify", "restore", "verify", "restore"])
+ self.assertTrue(result.wasSuccessful())
+
def test_expectation_failure_acts_appropriately(self):
class MyTest(MockerTestCase):
def test_method(self):