summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorSteve Purcell <steve@pythonconsulting.com>2001-04-09 15:37:31 (GMT)
committerSteve Purcell <steve@pythonconsulting.com>2001-04-09 15:37:31 (GMT)
commit17a781bc69d73326455ca7f129bdf57528f4ad8b (patch)
tree3c29d7c32f3e9c9525614e6621cad3991152dd77 /Lib/unittest.py
parenta36f4a0cd6cab640e93f0873a103ae832f59cb21 (diff)
downloadcpython-17a781bc69d73326455ca7f129bdf57528f4ad8b.zip
cpython-17a781bc69d73326455ca7f129bdf57528f4ad8b.tar.gz
cpython-17a781bc69d73326455ca7f129bdf57528f4ad8b.tar.bz2
* Remove exc_info() kludge -- it actually messed up the Jython output
* Fixed TestLoader.loadTestsFromName() for nested packages * Corrected the command-line usage summary
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index eac5e78..1c2163f 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -189,7 +189,7 @@ class TestCase:
try:
self.setUp()
except:
- result.addError(self,self.__exc_info())
+ result.addError(self,sys.exc_info())
return
ok = 0
@@ -197,14 +197,14 @@ class TestCase:
testMethod()
ok = 1
except AssertionError, e:
- result.addFailure(self,self.__exc_info())
+ result.addFailure(self,sys.exc_info())
except:
- result.addError(self,self.__exc_info())
+ result.addError(self,sys.exc_info())
try:
self.tearDown()
except:
- result.addError(self,self.__exc_info())
+ result.addError(self,sys.exc_info())
ok = 0
if ok: result.addSuccess(self)
finally:
@@ -266,17 +266,6 @@ class TestCase:
"""Fail immediately, with the given message."""
raise AssertionError, msg
- def __exc_info(self):
- """Return a version of sys.exc_info() with the traceback frame
- minimised; usually the top level of the traceback frame is not
- needed.
- """
- exctype, excvalue, tb = sys.exc_info()
- newtb = tb.tb_next
- if newtb is None:
- return (exctype, excvalue, tb)
- return (exctype, excvalue, newtb)
-
class TestSuite:
"""A test suite is a composite test consisting of a number of TestCases.
@@ -400,7 +389,14 @@ class TestLoader:
if not parts:
raise ValueError, "incomplete test name: %s" % name
else:
- module = __import__(parts)
+ parts_copy = parts[:]
+ while parts_copy:
+ try:
+ module = __import__(string.join(parts_copy,'.'))
+ break
+ except ImportError:
+ del parts_copy[-1]
+ if not parts_copy: raise
parts = parts[1:]
obj = module
for part in parts:
@@ -599,7 +595,7 @@ class TestProgram:
for making test modules conveniently executable.
"""
USAGE = """\
-Usage: %(progName)s [options] [test[:(casename|prefix-)]] [...]
+Usage: %(progName)s [options] [test] [...]
Options:
-h, --help Show this message