Commit c6879604 authored by Fred Drake's avatar Fred Drake

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.
parent d62f151a
...@@ -2,9 +2,7 @@ import hotshot ...@@ -2,9 +2,7 @@ import hotshot
import hotshot.log import hotshot.log
import os import os
import pprint import pprint
import sys
import unittest import unittest
import warnings
import test_support import test_support
...@@ -21,14 +19,29 @@ def shortfilename(fn): ...@@ -21,14 +19,29 @@ def shortfilename(fn):
return 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): class HotShotTestCase(unittest.TestCase):
def new_profiler(self, lineevents=0, linetimings=1): def new_profiler(self, lineevents=0, linetimings=1):
self.logfn = test_support.TESTFN self.logfn = test_support.TESTFN
return hotshot.Profile(self.logfn, lineevents, linetimings) return hotshot.Profile(self.logfn, lineevents, linetimings)
def get_logreader(self): def get_logreader(self):
log = hotshot.log.LogReader(self.logfn) log = UnlinkingLogReader(self.logfn)
#XXX os.unlink(self.logfn)
return log return log
def get_events_wotime(self): def get_events_wotime(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment