The doctest runner
| 622 | |
| 623 | |
| 624 | class DTRunner(doctest.DocTestRunner): |
| 625 | """ |
| 626 | The doctest runner |
| 627 | """ |
| 628 | DIVIDER = "\n" |
| 629 | |
| 630 | def __init__(self, item_name, checker=None, verbose=None, optionflags=0): |
| 631 | self._item_name = item_name |
| 632 | doctest.DocTestRunner.__init__(self, checker=checker, verbose=verbose, |
| 633 | optionflags=optionflags) |
| 634 | |
| 635 | def _report_item_name(self, out, new_line=False): |
| 636 | if self._item_name is not None: |
| 637 | if new_line: |
| 638 | out("\n") |
| 639 | self._item_name = None |
| 640 | |
| 641 | def report_start(self, out, test, example): |
| 642 | self._checker._source = example.source |
| 643 | return doctest.DocTestRunner.report_start(self, out, test, example) |
| 644 | |
| 645 | def report_success(self, out, test, example, got): |
| 646 | if self._verbose: |
| 647 | self._report_item_name(out, new_line=True) |
| 648 | return doctest.DocTestRunner.report_success(self, out, test, example, got) |
| 649 | |
| 650 | def report_unexpected_exception(self, out, test, example, exc_info): |
| 651 | self._report_item_name(out) |
| 652 | return doctest.DocTestRunner.report_unexpected_exception( |
| 653 | self, out, test, example, exc_info) |
| 654 | |
| 655 | def report_failure(self, out, test, example, got): |
| 656 | self._report_item_name(out) |
| 657 | return doctest.DocTestRunner.report_failure(self, out, test, |
| 658 | example, got) |
| 659 | |
| 660 | class Checker(doctest.OutputChecker): |
| 661 | """ |