[Python-checkins] CVS: python/dist/src/Lib/test test_support.py,1.17,1.18

Fred L. Drake fdrake@users.sourceforge.net
2001年3月21日 10:26:36 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv20393
Modified Files:
	test_support.py 
Log Message:
Just import sys at the top instead of inside lots of functions.
Add some helpers for supporting PyUNIT-based unit testing.
Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** test_support.py	2001年03月13日 09:31:07	1.17
--- test_support.py	2001年03月21日 18:26:33	1.18
***************
*** 1,5 ****
--- 1,7 ----
 """Supporting definitions for the Python regression test."""
 
+ import sys
 
+ 
 class Error(Exception):
 """Base class for regression test exceptions."""
***************
*** 22,26 ****
 
 def unload(name):
- import sys
 try:
 del sys.modules[name]
--- 24,27 ----
***************
*** 30,34 ****
 def forget(modname):
 unload(modname)
! import sys, os
 for dirname in sys.path:
 try:
--- 31,35 ----
 def forget(modname):
 unload(modname)
! import os
 for dirname in sys.path:
 try:
***************
*** 69,73 ****
 if os.path.isabs(file):
 return file
- import sys
 path = sys.path
 path = [os.path.dirname(here)] + path
--- 70,73 ----
***************
*** 94,95 ****
--- 94,127 ----
 else:
 print 'Missing SyntaxError: "%s"' % statement
+ 
+ 
+ 
+ #=======================================================================
+ # Preliminary PyUNIT integration.
+ 
+ import unittest
+ 
+ 
+ class BasicTestRunner(unittest.VerboseTextTestRunner):
+ def __init__(self, stream=sys.stderr):
+ unittest.VerboseTextTestRunner.__init__(self, stream, descriptions=0)
+ 
+ def run(self, test):
+ result = unittest._VerboseTextTestResult(self.stream, descriptions=0)
+ test(result)
+ return result
+ 
+ 
+ def run_unittest(testclass):
+ """Run tests from a unittest.TestCase-derived class."""
+ if verbose:
+ f = sys.stdout
+ else:
+ import StringIO
+ f = StringIO.StringIO()
+ 
+ suite = unittest.makeSuite(testclass)
+ result = BasicTestRunner(stream=f).run(suite)
+ if result.errors or result.failures:
+ raise TestFailed("errors occurred in %s.%s"
+ % (testclass.__module__, testclass.__name__))

AltStyle によって変換されたページ (->オリジナル) /