diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2008-03-28 19:39:41 -0300 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2008-03-28 19:39:41 -0300 |
commit | f21dc94aa7733ebcf5503359c47c97beb458e094 (patch) | |
tree | f0fad86816853741eb45e1bc84c4ee7f63f53ee2 | |
parent | d7c9c348405704cb69e9658df28d6008c5b2df7e (diff) | |
download | mocker-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.py | 2 | ||||
-rwxr-xr-x | test.py | 11 |
2 files changed, 12 insertions, 1 deletions
@@ -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) @@ -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): |