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