Print a summary of all the test cases that have been run by this DocTestRunner, and return a tuple `(f, t)`, where `f` is the total number of failed examples, and `t` is the total number of tried examples. The optional `verbose` argument controls how d
(self, verbose=None)
| 1532 | # Summarization |
| 1533 | #///////////////////////////////////////////////////////////////// |
| 1534 | def summarize(self, verbose=None): |
| 1535 | """ |
| 1536 | Print a summary of all the test cases that have been run by |
| 1537 | this DocTestRunner, and return a tuple `(f, t)`, where `f` is |
| 1538 | the total number of failed examples, and `t` is the total |
| 1539 | number of tried examples. |
| 1540 | |
| 1541 | The optional `verbose` argument controls how detailed the |
| 1542 | summary is. If the verbosity is not specified, then the |
| 1543 | DocTestRunner's verbosity is used. |
| 1544 | """ |
| 1545 | if verbose is None: |
| 1546 | verbose = self._verbose |
| 1547 | notests = [] |
| 1548 | passed = [] |
| 1549 | failed = [] |
| 1550 | totalt = totalf = 0 |
| 1551 | for x in self._name2ft.items(): |
| 1552 | name, (f, t) = x |
| 1553 | assert f <= t |
| 1554 | totalt += t |
| 1555 | totalf += f |
| 1556 | if t == 0: |
| 1557 | notests.append(name) |
| 1558 | elif f == 0: |
| 1559 | passed.append( (name, t) ) |
| 1560 | else: |
| 1561 | failed.append(x) |
| 1562 | if verbose: |
| 1563 | if notests: |
| 1564 | print(len(notests), "items had no tests:") |
| 1565 | notests.sort() |
| 1566 | for thing in notests: |
| 1567 | print(" ", thing) |
| 1568 | if passed: |
| 1569 | print(len(passed), "items passed all tests:") |
| 1570 | passed.sort() |
| 1571 | for thing, count in passed: |
| 1572 | print(" %3d tests in %s" % (count, thing)) |
| 1573 | if failed: |
| 1574 | print(self.DIVIDER) |
| 1575 | print(len(failed), "items had failures:") |
| 1576 | failed.sort() |
| 1577 | for thing, (f, t) in failed: |
| 1578 | print(" %3d of %3d in %s" % (f, t, thing)) |
| 1579 | if verbose: |
| 1580 | print(totalt, "tests in", len(self._name2ft), "items.") |
| 1581 | print(totalt - totalf, "passed and", totalf, "failed.") |
| 1582 | if totalf: |
| 1583 | print("***Test Failed***", totalf, "failures.") |
| 1584 | elif verbose: |
| 1585 | print("Test passed.") |
| 1586 | return TestResults(totalf, totalt) |
| 1587 | |
| 1588 | #///////////////////////////////////////////////////////////////// |
| 1589 | # Backward compatibility cruft to maintain doctest.master. |