|
20 | 20 |
|
21 | 21 | # NOTE: There are some additional tests relating to interaction with |
22 | 22 | # zipimport in the test_zipimport_support test module. |
| 23 | +# There are also related tests in `test_doctest2` module. |
23 | 24 |
|
24 | 25 | ###################################################################### |
25 | 26 | ## Sample Objects (used by test cases) |
@@ -455,7 +456,7 @@ def basics(): r""" |
455 | 456 | >>> tests = finder.find(sample_func) |
456 | 457 |
|
457 | 458 | >>> print(tests) # doctest: +ELLIPSIS |
458 | | - [<DocTest sample_func from test_doctest.py:28 (1 example)>] |
| 459 | + [<DocTest sample_func from test_doctest.py:29 (1 example)>] |
459 | 460 |
|
460 | 461 | The exact name depends on how test_doctest was invoked, so allow for |
461 | 462 | leading path components. |
@@ -637,6 +638,26 @@ def basics(): r""" |
637 | 638 | 1 SampleClass.double |
638 | 639 | 1 SampleClass.get |
639 | 640 |
|
| 641 | +When used with `exclude_empty=False` we are also interested in line numbers |
| 642 | +of doctests that are empty. |
| 643 | +It used to be broken for quite some time until `bpo-28249`. |
| 644 | +
|
| 645 | + >>> from test import doctest_lineno |
| 646 | + >>> tests = doctest.DocTestFinder(exclude_empty=False).find(doctest_lineno) |
| 647 | + >>> for t in tests: |
| 648 | + ... print('%5s %s' % (t.lineno, t.name)) |
| 649 | + None test.doctest_lineno |
| 650 | + 22 test.doctest_lineno.ClassWithDocstring |
| 651 | + 30 test.doctest_lineno.ClassWithDoctest |
| 652 | + None test.doctest_lineno.ClassWithoutDocstring |
| 653 | + None test.doctest_lineno.MethodWrapper |
| 654 | + 39 test.doctest_lineno.MethodWrapper.method_with_docstring |
| 655 | + 45 test.doctest_lineno.MethodWrapper.method_with_doctest |
| 656 | + None test.doctest_lineno.MethodWrapper.method_without_docstring |
| 657 | + 4 test.doctest_lineno.func_with_docstring |
| 658 | + 12 test.doctest_lineno.func_with_doctest |
| 659 | + None test.doctest_lineno.func_without_docstring |
| 660 | +
|
640 | 661 | Turning off Recursion |
641 | 662 | ~~~~~~~~~~~~~~~~~~~~~ |
642 | 663 | DocTestFinder can be told not to look for tests in contained objects |
|
0 commit comments