##// END OF EJS Templates
Refactor doctest-skipping implementation...
Nikita Kniazev -
Show More
@@ -37,35 +37,16 b' log = logging.getLogger(__name__)'
37 # Classes and functions
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 class DocTestFinder(doctest.DocTestFinder):
41 class DocTestFinder(doctest.DocTestFinder):
58 def _find(self, tests, obj, name, module, source_lines, globs, seen):
42 def _get_test(self, obj, name, module, globs, source_lines):
59 """
43 test = super()._get_test(obj, name, module, globs, source_lines)
60 Find tests for the given object and any contained objects, and
44
61 add them to `tests`.
45 if bool(getattr(obj, "__skip_doctest__", False)) and test is not None:
62 """
46 for example in test.examples:
63 print('_find for:', obj, name, module) # dbg
47 example.options[doctest.SKIP] = True
64 if bool(getattr(obj, "__skip_doctest__", False)):
65 #print 'SKIPPING DOCTEST FOR:',obj # dbg
66 obj = DocTestSkip(obj)
67
48
68 super()._find(tests, obj, name, module, source_lines, globs, seen)
49 return test
69
50
70
51
71 class IPDoctestOutputChecker(doctest.OutputChecker):
52 class IPDoctestOutputChecker(doctest.OutputChecker):
General Comments 0
You need to be logged in to leave comments. Login now