diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/testing/noseclasses.py | 42 | ||||
-rw-r--r-- | numpy/testing/nosetester.py | 11 |
2 files changed, 40 insertions, 13 deletions
diff --git a/numpy/testing/noseclasses.py b/numpy/testing/noseclasses.py index aae7c5da4..f97ea9126 100644 --- a/numpy/testing/noseclasses.py +++ b/numpy/testing/noseclasses.py @@ -295,14 +295,48 @@ class KnownFailure(ErrorClassPlugin): self.enabled = False - -# Because nose currently discards the test result object, but we need -# to return it to the user, override TestProgram.runTests to retain -# the result +class NpConfig(nose.core.Config): + ''' Class to pull out nose doctest plugin after configuration + + This allows the user to set doctest related settings in their + configuration. For example, without this fix, a setting of + 'with-doctest=1' in the user's .noserc file would cause an error, if + we remove the doctest extension before this stage. Our configure + uses the plugin to parse any settings, but then removed the doctest + plugin because the numpy doctester should be used for doctests + instead. + ''' + def __init__(self, config): + self.__dict__ = config.__dict__ + + def configure(self, *args, **kwargs): + super(NpConfig, self).configure(*args, **kwargs) + self.plugins.plugins = [p for p in self.plugins.plugins + if p.name != 'doctest'] + + +# Our class has two uses. First, to allow us to use NpConfig above to +# remove the doctest plugin after it has parsed the configuration. +# Second we save the results of the tests in runTests - see runTests +# method docstring for details class NumpyTestProgram(nose.core.TestProgram): + def makeConfig(self, *args, **kwargs): + """Load a Config, pre-filled with user config files if any are + found. + + We override this method only to allow us to return a NpConfig + object instead of a Config object. + """ + config = super(NumpyTestProgram, self).makeConfig(*args, **kwargs) + return NpConfig(config) + def runTests(self): """Run Tests. Returns true on success, false on failure, and sets self.success to the same value. + + Because nose currently discards the test result object, but we need + to return it to the user, override TestProgram.runTests to retain + the result """ if self.testRunner is None: self.testRunner = nose.core.TextTestRunner(stream=self.config.stream, diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index 03dc71ca3..9f345ad26 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -240,18 +240,11 @@ class NoseTester(object): nose = import_nose() - # construct list of plugins, omitting the existing doctest plugin + # construct list of plugins import nose.plugins.builtin from noseclasses import NumpyDoctest, KnownFailure plugins = [NumpyDoctest(), KnownFailure()] - for p in nose.plugins.builtin.plugins: - plug = p() - if plug.name == 'doctest': - # skip the builtin doctest plugin - continue - - plugins.append(plug) - + plugins += [p() for p in nose.plugins.builtin.plugins] return argv, plugins def test(self, label='fast', verbose=1, extra_argv=None, doctests=False, |