Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Only print 'and X failed' when non-zero
  • Loading branch information
hugovk committed Mar 25, 2024
commit 3e1f57f35d50b5d5afd8ab7627a32e7dce0e9e0d
5 changes: 3 additions & 2 deletions Lib/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ class DocTestRunner:
2 tests in _TestClass.get
1 tests in _TestClass.square
7 tests in 4 items.
7 passed and 0 failed.
7 passed.
Test passed.
TestResults(failed=0, attempted=7)

Expand Down Expand Up @@ -1603,7 +1603,8 @@ def summarize(self, verbose=None):
print(f" {failures:3d} of {tries:3d} in {name}")
if verbose:
print(f"{total_tries} tests in {len(self._stats)} items.")
print(f"{total_tries - total_failures} passed and {total_failures} failed.")
and_f = f" and {total_failures} failed" if total_failures else ""
print(f"{total_tries - total_failures} passed{and_f}.")
if total_failures:
msg = f"***Test Failed*** {total_failures} failures"
if total_skips:
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_doctest/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,7 @@ def test_testfile(): r"""
1 items passed all tests:
2 tests in test_doctest.txt
2 tests in 1 items.
2 passed and 0 failed.
2 passed.
Test passed.
TestResults(failed=0, attempted=2)
>>> doctest.master = None # Reset master.
Expand Down Expand Up @@ -2775,7 +2775,7 @@ def test_testfile(): r"""
1 items passed all tests:
2 tests in test_doctest4.txt
2 tests in 1 items.
2 passed and 0 failed.
2 passed.
Test passed.
TestResults(failed=0, attempted=2)
>>> doctest.master = None # Reset master.
Expand Down Expand Up @@ -3000,7 +3000,7 @@ def test_CLI(): r"""
1 items passed all tests:
2 tests in myfile.doc
2 tests in 1 items.
2 passed and 0 failed.
2 passed.
Test passed.

Now we'll write a couple files, one with three tests, the other a python module
Expand Down Expand Up @@ -3129,7 +3129,7 @@ def test_CLI(): r"""
1 items passed all tests:
3 tests in myfile.doc
3 tests in 1 items.
3 passed and 0 failed.
3 passed.
Test passed.
Trying:
1 + 1
Expand All @@ -3146,7 +3146,7 @@ def test_CLI(): r"""
1 items passed all tests:
2 tests in myfile2.test_func
2 tests in 2 items.
2 passed and 0 failed.
2 passed.
Test passed.

We should also check some typical error cases.
Expand Down