[Python-checkins] CVS: python/dist/src/Lib/test test_hotshot.py,1.2,1.3

Fred L. Drake fdrake@users.sourceforge.net
Fri, 12 Oct 2001 20:00:13 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv553

Modified Files:
	test_hotshot.py 
Log Message:
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.


Index: test_hotshot.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_hotshot.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_hotshot.py	2001/10/13 00:19:39	1.2
--- test_hotshot.py	2001/10/13 03:00:11	1.3
***************
*** 3,9 ****
  import os
  import pprint
- import sys
  import unittest
- import warnings
  
  import test_support
--- 3,7 ----
***************
*** 22,25 ****
--- 20,39 ----
  
  
+ 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):
***************
*** 28,33 ****
  
      def get_logreader(self):
!         log = hotshot.log.LogReader(self.logfn)
!         #XXX os.unlink(self.logfn)
          return log
  
--- 42,46 ----
  
      def get_logreader(self):
!         log = UnlinkingLogReader(self.logfn)
          return log