Skip to content

Commit 8274f38

Browse files
matthew-brettfperez
authored andcommitted
BF - allow nose with-doctest setting in environment
IPDoctest replaces the normal doctest plugin. Previously we did this by initializing the builtin plugins but skipping the doctest plugin. However, if the user has a noserc file with 'with-doctest=1' or the environment variable 'NOSE_WITH_DOCTEST', then nose will try and initialize the doctest plugin when it isn't there, and barf. This commit defers the removal of the doctest plugin to the configuration stage, so doctest can be enabled before it is thrown away by us.
1 parent 1a64b37 commit 8274f38

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

IPython/testing/iptest.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,19 +355,13 @@ def run_iptest():
355355
# for nose >= 0.11, though unfortunately nose 0.10 doesn't support it.
356356
argv.append('--traverse-namespace')
357357

358-
# Construct list of plugins, omitting the existing doctest plugin, which
359-
# ours replaces (and extends).
358+
# use our plugin for doctesting. It will remove the standard doctest plugin
359+
# if it finds it enabled
360360
plugins = [IPythonDoctest(make_exclude()), KnownFailure()]
361-
for p in nose.plugins.builtin.plugins:
362-
plug = p()
363-
if plug.name == 'doctest':
364-
continue
365-
plugins.append(plug)
366-
367361
# We need a global ipython running in this process
368362
globalipapp.start_ipython()
369363
# Now nose can run
370-
TestProgram(argv=argv, plugins=plugins)
364+
TestProgram(argv=argv, addplugins=plugins)
371365

372366

373367
def run_iptestall():

IPython/testing/plugin/ipdoctest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,9 @@ def options(self, parser, env=os.environ):
640640

641641
def configure(self, options, config):
642642
Plugin.configure(self, options, config)
643+
# Pull standard doctest plugin out of config; we will do doctesting
644+
config.plugins.plugins = [p for p in config.plugins.plugins
645+
if p.name != 'doctest']
643646
self.doctest_tests = options.doctest_tests
644647
self.extension = tolist(options.doctestExtension)
645648

@@ -783,6 +786,9 @@ def options(self, parser, env=os.environ):
783786
def configure(self, options, config):
784787
#print "Configuring nose plugin:", self.name # dbg
785788
Plugin.configure(self, options, config)
789+
# Pull standard doctest plugin out of config; we will do doctesting
790+
config.plugins.plugins = [p for p in config.plugins.plugins
791+
if p.name != 'doctest']
786792
self.doctest_tests = options.ipdoctest_tests
787793
self.extension = tolist(options.ipdoctest_extension)
788794

0 commit comments

Comments
 (0)