home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import os
- import os.path as path
- import sys
- import subprocess
- import tempfile
- import time
- import warnings
- import nose.plugins.builtin as nose
- from nose.core import TestProgram
- from IPython.platutils import find_cmd
- from IPython.testing.plugin.ipdoctest import IPythonDoctest
- pjoin = path.join
-
- def test_for(mod):
-
- try:
- __import__(mod)
- except ImportError:
- return False
-
- return True
-
- have_curses = test_for('_curses')
- have_wx = test_for('wx')
- have_wx_aui = test_for('wx.aui')
- have_zi = test_for('zope.interface')
- have_twisted = test_for('twisted')
- have_foolscap = test_for('foolscap')
- have_objc = test_for('objc')
- have_pexpect = test_for('pexpect')
- EXCLUDE = [
- pjoin('IPython', 'external'),
- pjoin('IPython', 'frontend', 'process', 'winprocess.py'),
- pjoin('IPython_doctest_plugin'),
- pjoin('IPython', 'Gnuplot'),
- pjoin('IPython', 'Extensions', 'ipy_'),
- pjoin('IPython', 'Extensions', 'PhysicalQInput'),
- pjoin('IPython', 'Extensions', 'PhysicalQInteractive'),
- pjoin('IPython', 'Extensions', 'InterpreterPasteInput'),
- 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_wx_aui:
- EXCLUDE.append(pjoin('IPython', 'gui', 'wx', 'wxIPython'))
-
- 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'))
-
- 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', 'irunner'))
-
- if not have_twisted:
- EXCLUDE.append(pjoin('IPython', 'frontend', 'asyncfrontendbase'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'prefilterfrontend'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'frontendbase'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'linefrontendbase'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', 'test_linefrontend'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', 'test_frontendbase'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', 'test_prefilterfrontend'))
- EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', 'test_asyncfrontendbase'))
- EXCLUDE.append(pjoin('IPython', 'kernel', 'error'))
- EXCLUDE.append(pjoin('IPython', 'testing', 'parametric'))
- EXCLUDE.append(pjoin('IPython', 'testing', 'util'))
- EXCLUDE.append(pjoin('IPython', 'testing', 'tests', 'test_decorators_trial'))
-
-
- def run_iptest():
- warnings.filterwarnings('ignore', 'This will be removed soon. Use IPython.testing.util instead')
- argv = sys.argv + [
- '--with-ipdoctest',
- '--ipdoctest-tests',
- '--ipdoctest-extension=txt',
- '--detailed-errors',
- '--exe']
- has_tests = False
- for arg in sys.argv:
- if ('IPython' in arg and arg.endswith('.py') or ':' in arg) and '.py' in arg:
- has_tests = True
- break
- continue
-
- if not has_tests:
- argv.append('IPython')
-
- plugins = [
- IPythonDoctest(EXCLUDE)]
- for p in nose.plugins.builtin.plugins:
- plug = p()
- if plug.name == 'doctest':
- continue
-
- plugins.append(plug)
-
- TestProgram(argv = argv, plugins = plugins)
-
-
- class IPTester(object):
-
- def __init__(self, runner = 'iptest', params = None):
- if runner == 'iptest':
- self.runner = [
- 'iptest',
- '-v']
- else:
- self.runner = [
- find_cmd('trial')]
- if params is None:
- params = []
-
- if isinstance(params, str):
- params = [
- params]
-
- self.params = params
- self.call_args = self.runner + self.params
-
- if sys.platform == 'win32':
-
- def run(self):
- curdir = os.getcwd()
- os.chdir(tempfile.gettempdir())
- stat = os.system(' '.join(self.call_args))
- os.chdir(curdir)
- return stat
-
- else:
-
- def run(self):
- return subprocess.call(self.call_args)
-
-
-
- def make_runners():
- top_mod = [
- 'background_jobs.py',
- 'ColorANSI.py',
- 'completer.py',
- 'ConfigLoader.py',
- 'CrashHandler.py',
- 'Debugger.py',
- 'deep_reload.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',
- 'ultraTB.py',
- 'upgrade_dir.py',
- 'usage.py',
- 'wildcard.py',
- 'winconsole.py']
- if have_twisted:
- top_mod.append('twshell.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')
- top_pack = [
- 'config',
- 'Extensions',
- 'frontend',
- 'testing',
- 'tests',
- 'tools',
- 'UserConfig']
- if have_wx:
- top_pack.append('gui')
-
- modules = [ 'IPython.%s' % m[:-3] for m in top_mod ]
- packages = [ 'IPython.%s' % m for m in top_pack ]
- runners = top_pack([]([], [ IPTester(params = v) for v in packages ]))
- runners['modules'] = IPTester(params = modules)
- return runners
-
-
- def run_iptestall():
- runners = make_runners()
- failed = { }
- t_start = time.time()
- for name, runner in runners.iteritems():
- print '*' * 77
- print 'IPython test group:', name
- res = runner.run()
- if res:
- failed[name] = res
- continue
-
- t_end = time.time()
- t_tests = t_end - t_start
- nrunners = len(runners)
- nfail = len(failed)
- print
- print '*' * 77
- print 'Ran %s test groups in %.3fs' % (nrunners, t_tests)
- print
- if not failed:
- print 'OK'
- else:
- print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners)
- for name in failed:
- failed_runner = runners[name]
- print '-' * 40
- print 'Runner failed:', name
- print 'You may wish to rerun this one individually, with:'
- print ' '.join(failed_runner.call_args)
- print
-
-
-
- def main():
- if len(sys.argv) == 1:
- run_iptestall()
- elif sys.argv[1] == 'all':
- run_iptestall()
- else:
- run_iptest()
-
- if __name__ == '__main__':
- main()
-
-