summaryrefslogtreecommitdiff
path: root/numpy/testing/noseclasses.py
diff options
context:
space:
mode:
authorMatthew Brett <matthew.brett@gmail.com>2009-12-29 16:54:26 +0000
committerMatthew Brett <matthew.brett@gmail.com>2009-12-29 16:54:26 +0000
commit0fef6e7813c9baa2c51d3f2eb8fa1352296c30b8 (patch)
treeec9b39ee006b5ebafe4a831c4212d608eda0db35 /numpy/testing/noseclasses.py
parente4f233ecfedd2aafa258db2d3ae27e30604cc020 (diff)
downloadnumpy-0fef6e7813c9baa2c51d3f2eb8fa1352296c30b8.tar.gz
FIX - allow doctest tester to parse config before being replaced by NumpyDocTest
Diffstat (limited to 'numpy/testing/noseclasses.py')
-rw-r--r--numpy/testing/noseclasses.py42
1 files changed, 38 insertions, 4 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,