New submission from Miki Tebeka:
python -mdoctest mymodule should return an error to the OS when a test
fails.
See patch.
----------
components: Library (Lib)
files: doctest.py.diff
messages: 58020
nosy: tebeka
severity: normal
status: open
title: doctest should return error if not all tests passed
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file8838/doctest.py.diff
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1530>
__________________________________
Index: doctest.py
===================================================================
--- doctest.py (revision 59247)
+++ doctest.py (working copy)
@@ -2646,6 +2646,7 @@
}
def _test():
+ passed = 1
testfiles = [arg for arg in sys.argv[1:] if arg and arg[0] != '-']
if testfiles:
for filename in testfiles:
@@ -2657,12 +2658,18 @@
sys.path.insert(0, dirname)
m = __import__(filename[:-3])
del sys.path[0]
- testmod(m)
+ failures, tries = testmod(m)
else:
- testfile(filename, module_relative=False)
+ failures, tries = testfile(filename, module_relative=False)
+ if failures:
+ passed = 0
else:
r = unittest.TextTestRunner()
r.run(DocTestSuite())
+ return passed
+
if __name__ == "__main__":
- _test()
+ passed = _test()
+ if not passed:
+ raise SystemExit(1)
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com