diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-12-07 07:51:38 -0200 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-12-07 07:51:38 -0200 |
commit | 92e4f5b0bc5ec7a06284b9cc2245fdfb052d9707 (patch) | |
tree | 783a715ae664d1a33b2a86b8b91ae08cb6215c54 /mocker.py | |
parent | bdfd5ccb1e2e22408371b26b806886e20b971285 (diff) | |
download | mocker-92e4f5b0bc5ec7a06284b9cc2245fdfb052d9707.tar.gz |
MockerTestCase.makeFile() with content=None (the default) now
consistently returns an unexistent temporary filename which
is properly cleaned up if created.
Diffstat (limited to 'mocker.py')
-rw-r--r-- | mocker.py | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -99,16 +99,14 @@ class MockerTestCase(unittest.TestCase): if test_method is not None: def test_method_wrapper(): try: - try: - result = test_method() - finally: - if (self.mocker.is_recording() and - self.mocker.get_events()): - raise RuntimeError("Mocker must be put in replay " - "mode with self.mocker.replay()") + result = test_method() except: raise else: + if (self.mocker.is_recording() and + self.mocker.get_events()): + raise RuntimeError("Mocker must be put in replay " + "mode with self.mocker.replay()") if (hasattr(result, "addCallback") and hasattr(result, "addErrback")): def verify(result): @@ -181,6 +179,8 @@ class MockerTestCase(unittest.TestCase): fd, path = tempfile.mkstemp(suffix, prefix, dirname) self.__cleanup_paths.append(path) os.close(fd) + if content is None: + os.unlink(path) if content is not None: file = open(path, "w") file.write(content) |