diff options
author | Fred Drake <fdrake@acm.org> | 2001-10-13 03:00:11 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-10-13 03:00:11 (GMT) |
commit | c6879604963786abbbf06659cabc5175f5e79a5f (patch) | |
tree | 613cb08a8705a089d04bc0e7b21ab0680911b99d /Lib/test | |
parent | d62f151a2c0b821bd43dbc1301706cf3619c5bcd (diff) | |
download | cpython-c6879604963786abbbf06659cabc5175f5e79a5f.zip cpython-c6879604963786abbbf06659cabc5175f5e79a5f.tar.gz cpython-c6879604963786abbbf06659cabc5175f5e79a5f.tar.bz2 |
Remove some unused imports.
Remove the log file after we are done with it. This should clean up after
the test even on Windows, since the file is now closed before we attempt
removal.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_hotshot.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Lib/test/test_hotshot.py b/Lib/test/test_hotshot.py index 4ddc907..84af776 100644 --- a/Lib/test/test_hotshot.py +++ b/Lib/test/test_hotshot.py @@ -2,9 +2,7 @@ import hotshot import hotshot.log import os import pprint -import sys import unittest -import warnings import test_support @@ -21,14 +19,29 @@ def shortfilename(fn): return fn +class UnlinkingLogReader(hotshot.log.LogReader): + """Extend the LogReader so the log file is unlinked when we're + done with it.""" + + def __init__(self, logfn): + self.__logfn = logfn + hotshot.log.LogReader.__init__(self, logfn) + + def next(self, index=None): + try: + return hotshot.log.LogReader.next(self) + except (IndexError, StopIteration): + os.unlink(self.__logfn) + raise + + class HotShotTestCase(unittest.TestCase): def new_profiler(self, lineevents=0, linetimings=1): self.logfn = test_support.TESTFN return hotshot.Profile(self.logfn, lineevents, linetimings) def get_logreader(self): - log = hotshot.log.LogReader(self.logfn) - #XXX os.unlink(self.logfn) + log = UnlinkingLogReader(self.logfn) return log def get_events_wotime(self): |