mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
* Remove exc_info() kludge -- it actually messed up the Jython output
* Fixed TestLoader.loadTestsFromName() for nested packages * Corrected the command-line usage summary
This commit is contained in:
parent
a36f4a0cd6
commit
17a781bc69
1 changed files with 13 additions and 17 deletions
|
@ -189,7 +189,7 @@ class TestCase:
|
||||||
try:
|
try:
|
||||||
self.setUp()
|
self.setUp()
|
||||||
except:
|
except:
|
||||||
result.addError(self,self.__exc_info())
|
result.addError(self,sys.exc_info())
|
||||||
return
|
return
|
||||||
|
|
||||||
ok = 0
|
ok = 0
|
||||||
|
@ -197,14 +197,14 @@ class TestCase:
|
||||||
testMethod()
|
testMethod()
|
||||||
ok = 1
|
ok = 1
|
||||||
except AssertionError, e:
|
except AssertionError, e:
|
||||||
result.addFailure(self,self.__exc_info())
|
result.addFailure(self,sys.exc_info())
|
||||||
except:
|
except:
|
||||||
result.addError(self,self.__exc_info())
|
result.addError(self,sys.exc_info())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.tearDown()
|
self.tearDown()
|
||||||
except:
|
except:
|
||||||
result.addError(self,self.__exc_info())
|
result.addError(self,sys.exc_info())
|
||||||
ok = 0
|
ok = 0
|
||||||
if ok: result.addSuccess(self)
|
if ok: result.addSuccess(self)
|
||||||
finally:
|
finally:
|
||||||
|
@ -266,17 +266,6 @@ class TestCase:
|
||||||
"""Fail immediately, with the given message."""
|
"""Fail immediately, with the given message."""
|
||||||
raise AssertionError, msg
|
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:
|
class TestSuite:
|
||||||
"""A test suite is a composite test consisting of a number of TestCases.
|
"""A test suite is a composite test consisting of a number of TestCases.
|
||||||
|
@ -400,7 +389,14 @@ class TestLoader:
|
||||||
if not parts:
|
if not parts:
|
||||||
raise ValueError, "incomplete test name: %s" % name
|
raise ValueError, "incomplete test name: %s" % name
|
||||||
else:
|
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:]
|
parts = parts[1:]
|
||||||
obj = module
|
obj = module
|
||||||
for part in parts:
|
for part in parts:
|
||||||
|
@ -599,7 +595,7 @@ class TestProgram:
|
||||||
for making test modules conveniently executable.
|
for making test modules conveniently executable.
|
||||||
"""
|
"""
|
||||||
USAGE = """\
|
USAGE = """\
|
||||||
Usage: %(progName)s [options] [test[:(casename|prefix-)]] [...]
|
Usage: %(progName)s [options] [test] [...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message
|
-h, --help Show this message
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue