def run_iptest(): """Run the IPython test suite using nose. This function is called when this script is **not** called with the form `iptest all`. It simply calls nose with appropriate command line flags and accepts all of the standard nose arguments. """ # Apply our monkeypatch to Xunit if '--with-xunit' in sys.argv and not hasattr(Xunit, 'orig_addError'): monkeypatch_xunit() warnings.filterwarnings( 'ignore', 'This will be removed soon. Use IPython.testing.util instead') if sys.argv[1] in special_test_suites: sys.argv[1:2] = special_test_suites[sys.argv[1]] special_suite = True else: special_suite = False argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks '--with-ipdoctest', '--ipdoctest-tests', '--ipdoctest-extension=txt', # We add --exe because of setuptools' imbecility (it # blindly does chmod +x on ALL files). Nose does the # right thing and it tries to avoid executables, # setuptools unfortunately forces our hand here. This # has been discussed on the distutils list and the # setuptools devs refuse to fix this problem! '--exe', ] if '-a' not in argv and '-A' not in argv: argv = argv + ['-a', '!crash'] if nose.__version__ >= '0.11': # I don't fully understand why we need this one, but depending on what # directory the test suite is run from, if we don't give it, 0 tests # get run. Specifically, if the test suite is run from the source dir # with an argument (like 'iptest.py IPython.core', 0 tests are run, # even if the same call done in this directory works fine). It appears # that if the requested package is in the current dir, nose bails early # by default. Since it's otherwise harmless, leave it in by default # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it. argv.append('--traverse-namespace') # use our plugin for doctesting. It will remove the standard doctest plugin # if it finds it enabled ipdt = IPythonDoctest() if special_suite else IPythonDoctest( make_exclude()) plugins = [ipdt, KnownFailure()] # We need a global ipython running in this process, but the special # in-process group spawns its own IPython kernels, so for *that* group we # must avoid also opening the global one (otherwise there's a conflict of # singletons). Ultimately the solution to this problem is to refactor our # assumptions about what needs to be a singleton and what doesn't (app # objects should, individual shells shouldn't). But for now, this # workaround allows the test suite for the inprocess module to complete. if not 'IPython.kernel.inprocess' in sys.argv: globalipapp.start_ipython() # Now nose can run TestProgram(argv=argv, addplugins=plugins)
def run_iptest(): """Run the IPython test suite using nose. This function is called when this script is **not** called with the form `iptest all`. It simply calls nose with appropriate command line flags and accepts all of the standard nose arguments. """ # Apply our monkeypatch to Xunit if '--with-xunit' in sys.argv and not hasattr(Xunit, 'orig_addError'): monkeypatch_xunit() arg1 = sys.argv[1] if arg1.startswith('IPython/'): if arg1.endswith('.py'): arg1 = arg1[:-3] sys.argv[1] = arg1.replace('/', '.') arg1 = sys.argv[1] if arg1 in test_sections: section = test_sections[arg1] sys.argv[1:2] = section.includes elif arg1.startswith('IPython.') and arg1[8:] in test_sections: section = test_sections[arg1[8:]] sys.argv[1:2] = section.includes else: section = TestSection(arg1, includes=[arg1]) argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks # We add --exe because of setuptools' imbecility (it # blindly does chmod +x on ALL files). Nose does the # right thing and it tries to avoid executables, # setuptools unfortunately forces our hand here. This # has been discussed on the distutils list and the # setuptools devs refuse to fix this problem! '--exe', ] if '-a' not in argv and '-A' not in argv: argv = argv + ['-a', '!crash'] if nose.__version__ >= '0.11': # I don't fully understand why we need this one, but depending on what # directory the test suite is run from, if we don't give it, 0 tests # get run. Specifically, if the test suite is run from the source dir # with an argument (like 'iptest.py IPython.core', 0 tests are run, # even if the same call done in this directory works fine). It appears # that if the requested package is in the current dir, nose bails early # by default. Since it's otherwise harmless, leave it in by default # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it. argv.append('--traverse-namespace') plugins = [ ExclusionPlugin(section.excludes), KnownFailure(), SubprocessStreamCapturePlugin() ] # we still have some vestigial doctests in core if (section.name.startswith(('core', 'IPython.core', 'IPython.utils'))): plugins.append(IPythonDoctest()) argv.extend([ '--with-ipdoctest', '--ipdoctest-tests', '--ipdoctest-extension=txt', ]) # Use working directory set by parent process (see iptestcontroller) if 'IPTEST_WORKING_DIR' in os.environ: os.chdir(os.environ['IPTEST_WORKING_DIR']) # We need a global ipython running in this process, but the special # in-process group spawns its own IPython kernels, so for *that* group we # must avoid also opening the global one (otherwise there's a conflict of # singletons). Ultimately the solution to this problem is to refactor our # assumptions about what needs to be a singleton and what doesn't (app # objects should, individual shells shouldn't). But for now, this # workaround allows the test suite for the inprocess module to complete. if 'kernel.inprocess' not in section.name: from IPython.testing import globalipapp globalipapp.start_ipython() # Now nose can run TestProgram(argv=argv, addplugins=plugins)
""" name = 'testconfig' can_configure = True enabled = True def options(self, parser, env): pass def configure(self, options, conf): pass def startTest(self, test): test_case = test.test.__class__ test_case.config_path = configpath TestProgram(argv=['fab', casepath], addplugins=[TestConfigPlugin()]) @task def test_perf(params=''): """ Runs the performance tests against the configured service and produce the report in dist/ :params str params: Parameters to pass to Funkload bench Examples:: fab dist.test_perf fab dist.test_perf:"-c 1:15 -D 1"
def startContext(self, ctx): try: n = ctx.__name__ except AttributeError: n = str(ctx) try: path = ctx.__file__.replace('.pyc', '.py') except AttributeError: path = '' channel.send(('start_ctx', n, path)) def stopContext(self, ctx): channel.send(('stop_ctx', )) def startTest(self, test): send('start', test) def stopTest(self, test): send('stop') if __name__ == '__channelexec__': cwd = channel.receive() os.chdir(cwd) prog = TestProgram( exit=False, argv=['--with-execnet'], plugins=[ChannelReporter()], )
def process_args(): tests = [] opts = None if sys.argv[-1].startswith("-"): test_names = sys.argv[1:-1] opts = sys.argv[-1] else: test_names = sys.argv[1:] for arg in test_names: arg = arg.strip() if len(arg) == 0: return a = arg.split("::") if len(a) == 1: # From module or folder a_splitted = a[0].split(";") if len(a_splitted) != 1: # means we have pattern to match against if a_splitted[0].endswith("/"): debug("/ from folder " + a_splitted[0] + ". Use pattern: " + a_splitted[1]) tests.append(a_splitted[0]) else: if a[0].endswith("/"): debug("/ from folder " + a[0]) tests.append(a[0]) else: debug("/ from module " + a[0]) tests.append(a[0]) elif len(a) == 2: # From testcase debug("/ from testcase " + a[1] + " in " + a[0]) tests.append(a[0] + ":" + a[1]) else: # From method in class or from function debug("/ from method " + a[2] + " in testcase " + a[1] + " in " + a[0]) if a[1] == "": # test function, not method tests.append(a[0] + ":" + a[2]) else: tests.append(a[0] + ":" + a[1] + "." + a[2]) argv = ['nosetests'] argv.extend(tests) if opts: options = shlex.split(opts) argv.extend(options) manager = DefaultPluginManager() manager.addPlugin(teamcity_plugin) config = MyConfig(plugins=manager) config.configure(argv) TestProgram(argv=argv, config=config, exit=False)