Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python-stdlib/unittest-discover/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(version="0.1.1")
metadata(version="0.1.2")

require("argparse")
require("fnmatch")
Expand Down
16 changes: 10 additions & 6 deletions python-stdlib/unittest-discover/unittest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def _dirname_filename_no_ext(path):


def discover_main():
failures = 0
runner = TestRunner()

if len(sys.argv) == 1 or (
Expand All @@ -121,22 +120,27 @@ def discover_main():
):
# No args, or `python -m unittest discover ...`.
result = _discover(runner)
failures += result.failuresNum or result.errorsNum
else:
result = TestResult()
for test_spec in sys.argv[1:]:
try:
os.stat(test_spec)
# File exists, strip extension and import with its parent directory in sys.path.
dirname, module_name = _dirname_filename_no_ext(test_spec)
result = _run_test_module(runner, module_name, dirname)
res = _run_test_module(runner, module_name, dirname)
except OSError:
# Not a file, treat as named module to import.
result = _run_test_module(runner, test_spec)
res = _run_test_module(runner, test_spec)

failures += result.failuresNum or result.errorsNum
result += res

if not result.testsRun:
# If tests are run their results are already printed.
# Ensure an appropriate output is printed if no tests are found.
runner.run(TestSuite())

# Terminate with non zero return code in case of failures.
sys.exit(failures)
sys.exit(result.failuresNum + result.errorsNum)


discover_main()
2 changes: 1 addition & 1 deletion python-stdlib/unittest/manifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
metadata(version="0.10.2")
metadata(version="0.10.3")

package("unittest")
7 changes: 4 additions & 3 deletions python-stdlib/unittest/unittest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ def wasSuccessful(self):
return self.errorsNum == 0 and self.failuresNum == 0

def printErrors(self):
print()
self.printErrorList(self.errors)
self.printErrorList(self.failures)
if self.errors or self.failures:
print()
self.printErrorList(self.errors)
self.printErrorList(self.failures)

def printErrorList(self, lst):
sep = "----------------------------------------------------------------------"
Expand Down