From 3b6b0915228a6fc81f48630ff6299b40136ec854 2009-07-27 22:38:27 From: Brian Granger Date: 2009-07-27 22:38:27 Subject: [PATCH] Refactored iptest.py to work with new package org. In the process I had to fix 2 small bugs to get all the tests passing. --- diff --git a/IPython/extensions/ibrowse.py b/IPython/extensions/ibrowse.py index fcbef75..809b4c9 100644 --- a/IPython/extensions/ibrowse.py +++ b/IPython/extensions/ibrowse.py @@ -2,7 +2,7 @@ import curses, fcntl, signal, struct, tty, textwrap, inspect -from IPython.coreZ import ipapi +from IPython.core import ipapi import astyle, ipipe diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index d793ca2..44b732e 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -56,55 +56,60 @@ have_foolscap = test_for('foolscap') have_objc = test_for('objc') have_pexpect = test_for('pexpect') -# For the IPythonDoctest plugin, we need to exclude certain patterns that cause -# testing problems. We should strive to minimize the number of skipped -# modules, since this means untested code. As the testing machinery -# solidifies, this list should eventually become empty. -EXCLUDE = [pjoin('IPython', 'external'), - pjoin('IPython', 'frontend', 'process', 'winprocess.py'), - pjoin('IPython_doctest_plugin'), - pjoin('IPython', 'Gnuplot'), - pjoin('IPython', 'extensions', 'ipy_'), - pjoin('IPython', 'extensions', 'clearcmd'), - pjoin('IPython', 'extensions', 'PhysicalQInteractive'), - pjoin('IPython', 'extensions', 'scitedirector'), - pjoin('IPython', 'extensions', 'numeric_formats'), - pjoin('IPython', 'testing', 'attic'), - pjoin('IPython', 'testing', 'tutils'), - pjoin('IPython', 'testing', 'tools'), - pjoin('IPython', 'testing', 'mkdoctests') - ] - -if not have_wx: - EXCLUDE.append(pjoin('IPython', 'extensions', 'igrid')) - EXCLUDE.append(pjoin('IPython', 'gui')) - EXCLUDE.append(pjoin('IPython', 'frontend', 'wx')) - -if not have_objc: - EXCLUDE.append(pjoin('IPython', 'frontend', 'cocoa')) - -if not have_curses: - EXCLUDE.append(pjoin('IPython', 'extensions', 'ibrowse')) - -if not sys.platform == 'win32': - EXCLUDE.append(pjoin('IPython', 'platutils_win32')) - -# These have to be skipped on win32 because the use echo, rm, cd, etc. -# See ticket https://bugs.launchpad.net/bugs/366982 -if sys.platform == 'win32': - EXCLUDE.append(pjoin('IPython', 'testing', 'plugin', 'test_exampleip')) - EXCLUDE.append(pjoin('IPython', 'testing', 'plugin', 'dtexample')) - -if not os.name == 'posix': - EXCLUDE.append(pjoin('IPython', 'platutils_posix')) - -if not have_pexpect: - EXCLUDE.append(pjoin('IPython', 'lib', 'irunner')) - -# This is needed for the reg-exp to match on win32 in the ipdoctest plugin. -if sys.platform == 'win32': - EXCLUDE = [s.replace('\\','\\\\') for s in EXCLUDE] +def make_exclude(): + + # For the IPythonDoctest plugin, we need to exclude certain patterns that cause + # testing problems. We should strive to minimize the number of skipped + # modules, since this means untested code. As the testing machinery + # solidifies, this list should eventually become empty. + EXCLUDE = [pjoin('IPython', 'external'), + pjoin('IPython', 'frontend', 'process', 'winprocess.py'), + pjoin('IPython_doctest_plugin'), + pjoin('IPython', 'extensions', 'ipy_'), + pjoin('IPython', 'extensions', 'clearcmd'), + pjoin('IPython', 'extensions', 'PhysicalQInteractive'), + pjoin('IPython', 'extensions', 'scitedirector'), + pjoin('IPython', 'extensions', 'numeric_formats'), + pjoin('IPython', 'testing', 'attic'), + pjoin('IPython', 'testing', 'tools'), + pjoin('IPython', 'testing', 'mkdoctests') + ] + + if not have_wx: + EXCLUDE.append(pjoin('IPython', 'extensions', 'igrid')) + EXCLUDE.append(pjoin('IPython', 'gui')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'wx')) + + if not have_objc: + EXCLUDE.append(pjoin('IPython', 'frontend', 'cocoa')) + + if not have_curses: + EXCLUDE.append(pjoin('IPython', 'extensions', 'ibrowse')) + + if not sys.platform == 'win32': + EXCLUDE.append(pjoin('IPython', 'utils', 'platutils_win32')) + + # These have to be skipped on win32 because the use echo, rm, cd, etc. + # See ticket https://bugs.launchpad.net/bugs/366982 + if sys.platform == 'win32': + EXCLUDE.append(pjoin('IPython', 'testing', 'plugin', 'test_exampleip')) + EXCLUDE.append(pjoin('IPython', 'testing', 'plugin', 'dtexample')) + + if not os.name == 'posix': + EXCLUDE.append(pjoin('IPython', 'utils', 'platutils_posix')) + + if not have_pexpect: + EXCLUDE.append(pjoin('IPython', 'scripts', 'irunner')) + + # Skip shell always because of a bug in FakeModule. + EXCLUDE.append(pjoin('IPython', 'core', 'shell')) + + # This is needed for the reg-exp to match on win32 in the ipdoctest plugin. + if sys.platform == 'win32': + EXCLUDE = [s.replace('\\','\\\\') for s in EXCLUDE] + + return EXCLUDE #----------------------------------------------------------------------------- # Functions and classes @@ -155,13 +160,12 @@ def run_iptest(): # Construct list of plugins, omitting the existing doctest plugin, which # ours replaces (and extends). + EXCLUDE = make_exclude() plugins = [IPythonDoctest(EXCLUDE)] for p in nose.plugins.builtin.plugins: plug = p() if plug.name == 'doctest': continue - - #print '*** adding plugin:',plug.name # dbg plugins.append(plug) TestProgram(argv=argv,plugins=plugins) @@ -191,55 +195,28 @@ class IPTester(object): def make_runners(): - """Define the modules and packages that need to be tested. + """Define the top-level packages that need to be tested. """ - - # This omits additional top-level modules that should not be doctested. - # XXX: shell.py is also ommited because of a bug in the skip_doctest - # decorator. See ticket https://bugs.launchpad.net/bugs/366209 - top_mod = \ - ['backgroundjobs.py', 'coloransi.py', 'completer.py', 'configloader.py', - 'crashhandler.py', 'debugger.py', 'deepreload.py', 'demo.py', - 'DPyGetOpt.py', 'dtutils.py', 'excolors.py', 'fakemodule.py', - 'generics.py', 'genutils.py', 'history.py', 'hooks.py', 'ipapi.py', - 'iplib.py', 'ipmaker.py', 'ipstruct.py', 'Itpl.py', - 'logger.py', 'macro.py', 'magic.py', 'oinspect.py', - 'outputtrap.py', 'platutils.py', 'prefilter.py', 'prompts.py', - 'PyColorize.py', 'release.py', 'rlineimpl.py', 'shadowns.py', - 'shellglobals.py', 'strdispatch.py', 'twshell.py', - 'ultratb.py', 'upgradedir.py', 'usage.py', 'wildcard.py', - # See note above for why this is skipped - # 'shell.py', - 'winconsole.py'] - - if have_pexpect: - top_mod.append('irunner.py') - - if sys.platform == 'win32': - top_mod.append('platutils_win32.py') - elif os.name == 'posix': - top_mod.append('platutils_posix.py') - else: - top_mod.append('platutils_dummy.py') - # These are tested by nose, so skip IPython.kernel - top_pack = ['config','extensions','frontend', - 'testing','tests','tools','userconfig'] + nose_packages = ['config', 'core', 'extensions', + 'frontend', 'lib', 'quarantine', + 'scripts', 'testing', 'utils'] + trial_packages = ['kernel'] if have_wx: - top_pack.append('gui') + nose_packages.append('gui') - modules = ['IPython.%s' % m[:-3] for m in top_mod ] - packages = ['IPython.%s' % m for m in top_pack ] + nose_packages = ['IPython.%s' % m for m in nose_packages ] + trial_packages = ['IPython.%s' % m for m in trial_packages ] # Make runners - runners = dict(zip(top_pack, [IPTester(params=v) for v in packages])) + runners = dict() - # Test IPython.kernel using trial if twisted is installed + nose_runners = dict(zip(nose_packages, [IPTester(params=v) for v in nose_packages])) if have_zi and have_twisted and have_foolscap: - runners['trial'] = IPTester('trial',['IPython']) - - runners['modules'] = IPTester(params=modules) + trial_runners = dict(zip(trial_packages, [IPTester('trial',params=v) for v in trial_packages])) + runners.update(nose_runners) + runners.update(trial_runners) return runners @@ -252,13 +229,15 @@ def run_iptestall(): and packages of IPython to be tested each in their own subprocess using nose or twisted.trial appropriately. """ + runners = make_runners() + # Run all test runners, tracking execution time failed = {} t_start = time.time() for name,runner in runners.iteritems(): print '*'*77 - print 'IPython test set:',name + print 'IPython test set:', name res = runner.run() if res: failed[name] = res diff --git a/IPython/utils/genutils.py b/IPython/utils/genutils.py index 85f5e3f..1fe1622 100644 --- a/IPython/utils/genutils.py +++ b/IPython/utils/genutils.py @@ -2178,7 +2178,7 @@ def extract_vars(*names,**kw): In [2]: def func(x): ...: y = 1 - ...: print extractVars('x','y') + ...: print extract_vars('x','y') ...: In [3]: func('hello')