From a26f8e3c74bb5b1f4ed24689d1592580ac4c59ac 2008-11-10 02:51:27 From: Fernando Perez Date: 2008-11-10 02:51:27 Subject: [PATCH] Override makeTest to correctly support path/to/test.py:test_function syntax. If we don't explicitly override this, the checker used isn't IPython-aware and we don't get full support for things like #random markers, when using the syntax:: iptest tests/test_magic.py:doctest_clear_array --- diff --git a/IPython/testing/plugin/ipdoctest.py b/IPython/testing/plugin/ipdoctest.py index 127c4f9..d12eaec 100644 --- a/IPython/testing/plugin/ipdoctest.py +++ b/IPython/testing/plugin/ipdoctest.py @@ -806,6 +806,23 @@ class IPythonDoctest(ExtensionDoctest): name = 'ipdoctest' # call nosetests with --with-ipdoctest enabled = True + def makeTest(self, obj, parent): + """Look for doctests in the given object, which will be a + function, method or class. + """ + # always use whitespace and ellipsis options + optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + + doctests = self.finder.find(obj, module=getmodule(parent)) + if doctests: + for test in doctests: + if len(test.examples) == 0: + continue + + yield DocTestCase(test, obj=obj, + optionflags=optionflags, + checker=self.checker) + def configure(self, options, config): Plugin.configure(self, options, config)