Find tests for the given object and any contained objects, and add them to `tests`.
(self, tests, obj, name, module, source_lines, globs, seen)
| 118 | raise ValueError("object must be a class or function, got %r" % object) |
| 119 | |
| 120 | def _find(self, tests, obj, name, module, source_lines, globs, seen): |
| 121 | """ |
| 122 | Find tests for the given object and any contained objects, and |
| 123 | add them to `tests`. |
| 124 | """ |
| 125 | print('_find for:', obj, name, module) # dbg |
| 126 | if hasattr(obj,"skip_doctest"): |
| 127 | #print 'SKIPPING DOCTEST FOR:',obj # dbg |
| 128 | obj = DocTestSkip(obj) |
| 129 | |
| 130 | doctest.DocTestFinder._find(self,tests, obj, name, module, |
| 131 | source_lines, globs, seen) |
| 132 | |
| 133 | # Below we re-run pieces of the above method with manual modifications, |
| 134 | # because the original code is buggy and fails to correctly identify |
| 135 | # doctests in extension modules. |
| 136 | |
| 137 | # Local shorthands |
| 138 | from inspect import isroutine, isclass |
| 139 | |
| 140 | # Look for tests in a module's contained objects. |
| 141 | if inspect.ismodule(obj) and self._recurse: |
| 142 | for valname, val in obj.__dict__.items(): |
| 143 | valname1 = '%s.%s' % (name, valname) |
| 144 | if ( (isroutine(val) or isclass(val)) |
| 145 | and self._from_module(module, val) ): |
| 146 | |
| 147 | self._find(tests, val, valname1, module, source_lines, |
| 148 | globs, seen) |
| 149 | |
| 150 | # Look for tests in a class's contained objects. |
| 151 | if inspect.isclass(obj) and self._recurse: |
| 152 | #print 'RECURSE into class:',obj # dbg |
| 153 | for valname, val in obj.__dict__.items(): |
| 154 | # Special handling for staticmethod/classmethod. |
| 155 | if isinstance(val, staticmethod): |
| 156 | val = getattr(obj, valname) |
| 157 | if isinstance(val, classmethod): |
| 158 | val = getattr(obj, valname).__func__ |
| 159 | |
| 160 | # Recurse to methods, properties, and nested classes. |
| 161 | if ((inspect.isfunction(val) or inspect.isclass(val) or |
| 162 | inspect.ismethod(val) or |
| 163 | isinstance(val, property)) and |
| 164 | self._from_module(module, val)): |
| 165 | valname = '%s.%s' % (name, valname) |
| 166 | self._find(tests, val, valname, module, source_lines, |
| 167 | globs, seen) |
| 168 | |
| 169 | |
| 170 | class IPDoctestOutputChecker(doctest.OutputChecker): |
nothing calls this directly
no test coverage detected