mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
Merged revisions 76937 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
r76934 does not apply and was deleted in the merge.
................
r76937 | r.david.murray | 2009-12-20 12:28:31 -0500 (Sun, 20 Dec 2009) | 20 lines
Merged revisions 76934-76935 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76934 | r.david.murray | 2009-12-20 11:24:46 -0500 (Sun, 20 Dec 2009) | 2 lines
Fix comment typo.
........
r76935 | r.david.murray | 2009-12-20 11:46:06 -0500 (Sun, 20 Dec 2009) | 10 lines
Issue #7376: When called with no arguments doctest was running a
self-test. Because of a change to the way tracebacks are printed,
this self-test was failing. The test is run (and passes) during normal
regression testing. So instead of running the failing self-test this
patch makes doctest emit a usage message. This is better behavior anyway
since passing in arguments is the real reason to run doctest as a command.
Bug discovery and initial patch by Florent Xicluna.
........
................
This commit is contained in:
parent
d56ce975fb
commit
14520958ee
2 changed files with 25 additions and 18 deletions
|
|
@ -2611,27 +2611,31 @@ __test__ = {"_TestClass": _TestClass,
|
||||||
""",
|
""",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _test():
|
def _test():
|
||||||
testfiles = [arg for arg in sys.argv[1:] if arg and arg[0] != '-']
|
testfiles = [arg for arg in sys.argv[1:] if arg and arg[0] != '-']
|
||||||
if testfiles:
|
if not testfiles:
|
||||||
for filename in testfiles:
|
name = os.path.basename(sys.argv[0])
|
||||||
if filename.endswith(".py"):
|
if '__loader__' in globals() and name.endswith('.py'): # python -m
|
||||||
# It is a module -- insert its dir into sys.path and try to
|
name, _ = os.path.splitext(name)
|
||||||
# import it. If it is part of a package, that possibly won't work
|
print("usage: {0} [-v] file ...".format(name))
|
||||||
# because of package imports.
|
return 2
|
||||||
dirname, filename = os.path.split(filename)
|
for filename in testfiles:
|
||||||
sys.path.insert(0, dirname)
|
if filename.endswith(".py"):
|
||||||
m = __import__(filename[:-3])
|
# It is a module -- insert its dir into sys.path and try to
|
||||||
del sys.path[0]
|
# import it. If it is part of a package, that possibly
|
||||||
failures, _ = testmod(m)
|
# won't work because of package imports.
|
||||||
else:
|
dirname, filename = os.path.split(filename)
|
||||||
failures, _ = testfile(filename, module_relative=False)
|
sys.path.insert(0, dirname)
|
||||||
if failures:
|
m = __import__(filename[:-3])
|
||||||
return 1
|
del sys.path[0]
|
||||||
else:
|
failures, _ = testmod(m)
|
||||||
r = unittest.TextTestRunner()
|
else:
|
||||||
r.run(DocTestSuite())
|
failures, _ = testfile(filename, module_relative=False)
|
||||||
|
if failures:
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(_test())
|
sys.exit(_test())
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,9 @@ Extension Modules
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #7376: instead of running a self-test (which was failing) when called
|
||||||
|
with no arguments, doctest.py now gives a usage message.
|
||||||
|
|
||||||
- Issue #7498: test_multiprocessing now uses test.support.find_unused_port
|
- Issue #7498: test_multiprocessing now uses test.support.find_unused_port
|
||||||
instead of a hardcoded port number in test_rapid_restart.
|
instead of a hardcoded port number in test_rapid_restart.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue