|
37 | 37 | # Classes and functions |
38 | 38 | #----------------------------------------------------------------------------- |
39 | 39 |
|
40 | | -class DocTestSkip(object): |
41 | | - """Object wrapper for doctests to be skipped.""" |
42 | | - |
43 | | - ds_skip = """Doctest to skip. |
44 | | - >>> 1 #doctest: +SKIP |
45 | | - """ |
46 | | - |
47 | | - def __init__(self,obj): |
48 | | - self.obj = obj |
49 | | - |
50 | | - def __getattribute__(self,key): |
51 | | - if key == '__doc__': |
52 | | - return DocTestSkip.ds_skip |
53 | | - else: |
54 | | - return getattr(object.__getattribute__(self,'obj'),key) |
55 | | - |
56 | 40 |
|
57 | 41 | class DocTestFinder(doctest.DocTestFinder): |
58 | | - def _find(self, tests, obj, name, module, source_lines, globs, seen): |
59 | | - """ |
60 | | - Find tests for the given object and any contained objects, and |
61 | | - add them to `tests`. |
62 | | - """ |
63 | | - print('_find for:', obj, name, module) # dbg |
64 | | - if bool(getattr(obj, "__skip_doctest__", False)): |
65 | | - #print 'SKIPPING DOCTEST FOR:',obj # dbg |
66 | | - obj = DocTestSkip(obj) |
| 42 | + def _get_test(self, obj, name, module, globs, source_lines): |
| 43 | + test = super()._get_test(obj, name, module, globs, source_lines) |
| 44 | + |
| 45 | + if bool(getattr(obj, "__skip_doctest__", False)) and test is not None: |
| 46 | + for example in test.examples: |
| 47 | + example.options[doctest.SKIP] = True |
67 | 48 |
|
68 | | - super()._find(tests, obj, name, module, source_lines, globs, seen) |
| 49 | + return test |
69 | 50 |
|
70 | 51 |
|
71 | 52 | class IPDoctestOutputChecker(doctest.OutputChecker): |
|
0 commit comments