Show More
@@ -115,7 +115,16 b' start_ipython()' | |||
|
115 | 115 | # *** END HACK *** |
|
116 | 116 | ########################################################################### |
|
117 | 117 | |
|
118 | #----------------------------------------------------------------------------- | |
|
118 | # Classes and functions | |
|
119 | ||
|
120 | def is_extension_module(filename): | |
|
121 | """Return whether the given filename is an extension module. | |
|
122 | ||
|
123 | This simply checks that the extension is either .so or .pyd. | |
|
124 | """ | |
|
125 | return os.path.splitext(filename)[1].lower() in ('.so','.pyd') | |
|
126 | ||
|
127 | ||
|
119 | 128 | # Modified version of the one in the stdlib, that fixes a python bug (doctests |
|
120 | 129 | # not found in extension modules, http://bugs.python.org/issue3158) |
|
121 | 130 | class DocTestFinder(doctest.DocTestFinder): |
@@ -157,8 +166,6 b' class DocTestFinder(doctest.DocTestFinder):' | |||
|
157 | 166 | else: |
|
158 | 167 | raise ValueError("object must be a class or function") |
|
159 | 168 | |
|
160 | ||
|
161 | ||
|
162 | 169 | def _find(self, tests, obj, name, module, source_lines, globs, seen): |
|
163 | 170 | """ |
|
164 | 171 | Find tests for the given object and any contained objects, and |
@@ -185,7 +192,6 b' class DocTestFinder(doctest.DocTestFinder):' | |||
|
185 | 192 | self._find(tests, val, valname1, module, source_lines, |
|
186 | 193 | globs, seen) |
|
187 | 194 | |
|
188 | ||
|
189 | 195 | # Look for tests in a class's contained objects. |
|
190 | 196 | if inspect.isclass(obj) and self._recurse: |
|
191 | 197 | #print 'RECURSE into class:',obj # dbg |
@@ -229,20 +235,11 b' class DocTestCase(doctests.DocTestCase):' | |||
|
229 | 235 | return name |
|
230 | 236 | |
|
231 | 237 | |
|
232 | # Classes and functions | |
|
233 | ||
|
234 | def is_extension_module(filename): | |
|
235 | """Return whether the given filename is an extension module. | |
|
236 | ||
|
237 | This simply checks that the extension is either .so or .pyd. | |
|
238 | """ | |
|
239 | return os.path.splitext(filename)[1].lower() in ('.so','.pyd') | |
|
240 | ||
|
241 | ||
|
242 | 238 | # A simple subclassing of the original with a different class name, so we can |
|
243 | 239 | # distinguish and treat differently IPython examples from pure python ones. |
|
244 | 240 | class IPExample(doctest.Example): pass |
|
245 | 241 | |
|
242 | ||
|
246 | 243 | class IPExternalExample(doctest.Example): |
|
247 | 244 | """Doctest examples to be run in an external process.""" |
|
248 | 245 | |
@@ -254,6 +251,7 b' class IPExternalExample(doctest.Example):' | |||
|
254 | 251 | # An EXTRA newline is needed to prevent pexpect hangs |
|
255 | 252 | self.source += '\n' |
|
256 | 253 | |
|
254 | ||
|
257 | 255 | class IPDocTestParser(doctest.DocTestParser): |
|
258 | 256 | """ |
|
259 | 257 | A class used to parse strings containing doctest examples. |
@@ -466,7 +464,6 b' class IPDocTestParser(doctest.DocTestParser):' | |||
|
466 | 464 | |
|
467 | 465 | SKIP = doctest.register_optionflag('SKIP') |
|
468 | 466 | |
|
469 | ########################################################################### | |
|
470 | 467 | |
|
471 | 468 | class DocFileCase(doctest.DocFileCase): |
|
472 | 469 | """Overrides to provide filename |
@@ -529,7 +526,6 b' class ExtensionDoctest(doctests.Doctest):' | |||
|
529 | 526 | else: |
|
530 | 527 | yield False # no tests to load |
|
531 | 528 | |
|
532 | ||
|
533 | 529 | def wantFile(self,filename): |
|
534 | 530 | """Return whether the given filename should be scanned for tests. |
|
535 | 531 | |
@@ -585,6 +581,7 b' class ExtensionDoctest(doctests.Doctest):' | |||
|
585 | 581 | test.filename = module_file |
|
586 | 582 | yield DocTestCase(test) |
|
587 | 583 | |
|
584 | ||
|
588 | 585 | class IPythonDoctest(ExtensionDoctest): |
|
589 | 586 | """Nose Plugin that supports doctests in extension modules. |
|
590 | 587 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now