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

Skip to content

Commit 5508629

Browse files
committed
Refactor doctest-skipping implementation
The old one rewrites docstring which creates a doctest where is no examples presented in the docstring.
1 parent c70d548 commit 5508629

1 file changed

Lines changed: 7 additions & 26 deletions

File tree

IPython/testing/plugin/ipdoctest.py

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,16 @@
3737
# Classes and functions
3838
#-----------------------------------------------------------------------------
3939

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-
5640

5741
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
6748

68-
super()._find(tests, obj, name, module, source_lines, globs, seen)
49+
return test
6950

7051

7152
class IPDoctestOutputChecker(doctest.OutputChecker):

0 commit comments

Comments
 (0)