summaryrefslogtreecommitdiff
path: root/mocker.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2007-12-07 07:51:38 -0200
committerGustavo Niemeyer <gustavo@niemeyer.net>2007-12-07 07:51:38 -0200
commit92e4f5b0bc5ec7a06284b9cc2245fdfb052d9707 (patch)
tree783a715ae664d1a33b2a86b8b91ae08cb6215c54 /mocker.py
parentbdfd5ccb1e2e22408371b26b806886e20b971285 (diff)
downloadmocker-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.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/mocker.py b/mocker.py
index 99450d7..5f8572b 100644
--- a/mocker.py
+++ b/mocker.py
@@ -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)