コード例 #1
0
def run():
    # This is a fix to allow the --hide-elapsed flag while accepting
    # arbitrary nosetest flags as well
    argv = [x for x in sys.argv if x != '--hide-elapsed']
    hide_elapsed = argv != sys.argv
    logging.setup()

    # If any argument looks like a test name but doesn't have "nova.tests" in
    # front of it, automatically add that so we don't have to type as much
    for i, arg in enumerate(argv):
        if arg.startswith('test_'):
            argv[i] = 'nova.tests.%s' % arg

    testdir = os.path.abspath(os.path.join("nova", "tests"))
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=testdir,
                      plugins=core.DefaultPluginManager())

    runner = NovaTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c,
                            show_elapsed=not hide_elapsed)
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
コード例 #2
0
ファイル: runner.py プロジェクト: yamahata/nova
def run():
    logging.setup()
    # If any argument looks like a test name but doesn't have "nova.tests" in
    # front of it, automatically add that so we don't have to type as much
    show_elapsed = True
    argv = []
    for x in sys.argv:
        if x.startswith('test_'):
            argv.append('nova.tests.%s' % x)
        elif x.startswith('--hide-elapsed'):
            show_elapsed = False
        else:
            argv.append(x)

    testdir = os.path.abspath(os.path.join("nova", "tests"))
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=testdir,
                      plugins=core.DefaultPluginManager())

    runner = NovaTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c,
                            show_elapsed=show_elapsed)
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
コード例 #3
0
def main():
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      includeExe=True,
                      traverseNamespace=True,
                      plugins=core.DefaultPluginManager())
    c.configureWhere(quantum.tests.unit.__path__)
    sys.exit(run_tests(c))
コード例 #4
0
def get_default_config(**kwargs):
    """Returns a configuration file set up with our default settings
    Extra arguments can be passed in through kwargs"""
    kwargs.setdefault("verbosity", 2)
    kwargs.setdefault("includeExe", True)
    kwargs.setdefault("testMatch", re.compile("^[Tt]est"))
    if "plugins" not in kwargs:
        kwargs["plugins"] = plugins.DefaultPluginManager()
    return config.Config(**kwargs)
コード例 #5
0
ファイル: __init__.py プロジェクト: bodepd/keystone
    def run(self, args=None):
        try:
            self.setUp()

            # discover and run tests
            # TODO(zns): check if we still need a verbosity flag
            verbosity = 1
            if '--verbose' in sys.argv:
                verbosity = 2

            # If any argument looks like a test name but doesn't have
            # "nova.tests" in front of it, automatically add that so we don't
            # have to type as much
            show_elapsed = True
            argv = []
            if args is None:
                args = sys.argv
            has_base = False
            for x in args:
                if x.startswith(('functional', 'unit', 'client')):
                    argv.append('keystone.test.%s' % x)
                    has_base = True
                elif x.startswith('--hide-elapsed'):
                    show_elapsed = False
                elif x.startswith('--trace-calls'):
                    pass
                elif x.startswith('--debug'):
                    pass
                elif x.startswith('-'):
                    argv.append(x)
                else:
                    argv.append(x)
                    if x != args[0]:
                        has_base = True

            if not has_base and self.directory_base is not None:
                argv.append(self.directory_base)

            c = noseconfig.Config(stream=sys.stdout,
                                  env=os.environ,
                                  verbosity=3,
                                  workingDir=TEST_DIR,
                                  plugins=core.DefaultPluginManager())

            runner = NovaTestRunner(stream=c.stream,
                                    verbosity=c.verbosity,
                                    config=c,
                                    show_elapsed=show_elapsed)

            return not core.run(config=c,
                                testRunner=runner,
                                argv=argv + ['--no-path-adjustment'])
        finally:
            self.tearDown()
コード例 #6
0
ファイル: run_tests.py プロジェクト: whitekid/quantum
def main():

    test_config['plugin_name'] = "l2network_plugin.L2Network"
    cwd = os.getcwd()
    os.chdir(cwd)
    working_dir = os.path.abspath("quantum/plugins/cisco")
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=working_dir)
    sys.exit(run_tests(c))
コード例 #7
0
ファイル: base.py プロジェクト: zenpwning/CloudFerry
def get_nosetest_cmd_attribute_val(attribute):
    env = os.environ
    manager = nose_manager.DefaultPluginManager()
    cfg_files = nose_config.all_config_files()
    tmp_config = nose_config.Config(env=env, files=cfg_files, plugins=manager)
    tmp_config.configure()
    try:
        attr_list = getattr(tmp_config.options, 'attr')
        value = dict(token.split('=') for token in attr_list)
        return value[attribute]
    except TypeError:
        return None
コード例 #8
0
ファイル: testrunner.py プロジェクト: mgosalia/mom
def run():
    argv = sys.argv
    stream = sys.stdout
    verbosity = 3
    testdir = os.path.dirname(os.path.abspath(__file__))

    conf = config.Config(stream=stream,
                         env=os.environ,
                         verbosity=verbosity,
                         workingDir=testdir,
                         plugins=core.DefaultPluginManager())

    sys.exit(not core.run(config=conf, argv=argv))
コード例 #9
0
ファイル: __init__.py プロジェクト: OpenStack-Kha/keystone
    def run(self, args=None):
        try:
            print 'Running test suite: %s' % self.__class__.__name__

            self.setUp()

            # discover and run tests

            # If any argument looks like a test name but doesn't have
            # "keystone.test" in front of it, automatically add that so we
            # don't have to type as much
            show_elapsed = True
            argv = []
            if args is None:
                args = sys.argv
            has_base = False
            for x in args:
                if x.startswith(('functional', 'unit', 'client')):
                    argv.append('keystone.test.%s' % x)
                    has_base = True
                elif x.startswith('--hide-elapsed'):
                    show_elapsed = False
                elif x.startswith('-'):
                    argv.append(x)
                else:
                    argv.append(x)
                    if x != args[0]:
                        has_base = True

            if not has_base and self.directory_base is not None:
                argv.append(self.directory_base)
            argv = ['--no-path-adjustment'] + argv[1:]
            logger.debug("Running set of tests with args=%s" % argv)

            c = noseconfig.Config(stream=sys.stdout,
                                  env=os.environ,
                                  verbosity=3,
                                  workingDir=TEST_DIR,
                                  plugins=core.DefaultPluginManager(),
                                  args=argv)

            runner = NovaTestRunner(stream=c.stream,
                                    verbosity=c.verbosity,
                                    config=c,
                                    show_elapsed=show_elapsed)

            result = not core.run(config=c, testRunner=runner, argv=argv)
            return int(result)  # convert to values applicable to sys.exit()
        except Exception, exc:
            logger.exception(exc)
            raise exc
コード例 #10
0
ファイル: testlib.py プロジェクト: rexhsu/vdsm
def run():
    argv = sys.argv
    stream = sys.stdout
    testdir = os.path.dirname(os.path.abspath(__file__))

    conf = config.Config(stream=stream,
                         env=os.environ,
                         workingDir=testdir,
                         plugins=core.DefaultPluginManager())
    conf.plugins.addPlugin(SlowTestsPlugin())
    conf.plugins.addPlugin(StressTestsPlugin())

    runner = VdsmTestRunner(stream=conf.stream,
                            verbosity=conf.verbosity,
                            config=conf)

    sys.exit(not core.run(config=conf, testRunner=runner, argv=argv))
コード例 #11
0
            self.stream.flush()


class NovaTestRunner(core.TextTestRunner):
    def _makeResult(self):
        return NovaTestResult(self.stream,
                              self.descriptions,
                              self.verbosity,
                              self.config)


if __name__ == '__main__':
    if not os.getenv('EC2_ACCESS_KEY'):
        print _('Missing EC2 environment variables. Please '
                'source the appropriate novarc file before '
                'running this test.')
        sys.exit(1)

    argv = FLAGS(sys.argv)
    testdir = os.path.abspath("./")
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=testdir,
                      plugins=core.DefaultPluginManager())

    runner = NovaTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c)
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
コード例 #12
0
def run_main(test_importer):

    add_support_for_localization()

    # Strip non-nose arguments out before passing this to nosetests

    repl = False
    nose_args = []
    conf_file = "~/test.conf"
    show_elapsed = True
    groups = []
    print("RUNNING TEST ARGS :  " + str(sys.argv))
    extra_test_conf_lines = []
    rdl_config_file = None
    nova_flag_file = None
    index = 0
    while index < len(sys.argv):
        arg = sys.argv[index]
        if arg[:2] == "-i" or arg == '--repl':
            repl = True
        elif arg[:7] == "--conf=":
            conf_file = os.path.expanduser(arg[7:])
            print("Setting TEST_CONF to " + conf_file)
            os.environ["TEST_CONF"] = conf_file
        elif arg[:8] == "--group=":
            groups.append(arg[8:])
        elif arg == "--test-config":
            if index >= len(sys.argv) - 1:
                print('Expected an argument to follow "--test-conf".')
                sys.exit()
            conf_line = sys.argv[index + 1]
            extra_test_conf_lines.append(conf_line)
        elif arg[:11] == "--flagfile=":
            pass
        elif arg[:14] == "--config-file=":
            rdl_config_file = arg[14:]
        elif arg[:13] == "--nova-flags=":
            nova_flag_file = arg[13:]
        elif arg.startswith('--hide-elapsed'):
            show_elapsed = False
        else:
            nose_args.append(arg)
        index += 1

    # Many of the test decorators depend on configuration values, so before
    # start importing modules we have to load the test config followed by the
    # flag files.
    from trove.tests.config import CONFIG

    # Find config file.
    if not "TEST_CONF" in os.environ:
        raise RuntimeError("Please define an environment variable named " +
                           "TEST_CONF with the location to a conf file.")
    file_path = os.path.expanduser(os.environ["TEST_CONF"])
    if not os.path.exists(file_path):
        raise RuntimeError("Could not find TEST_CONF at " + file_path + ".")
        # Load config file and then any lines we read from the arguments.
    CONFIG.load_from_file(file_path)
    for line in extra_test_conf_lines:
        CONFIG.load_from_line(line)

    if CONFIG.white_box:  # If white-box testing, set up the flags.
        # Handle loading up RDL's config file madness.
        initialize_rdl_config(rdl_config_file)

    # Set up the report, and print out how we're running the tests.
    from tests.util import report
    from datetime import datetime
    report.log("Trove Integration Tests, %s" % datetime.now())
    report.log("Invoked via command: " + str(sys.argv))
    report.log("Groups = " + str(groups))
    report.log("Test conf file = %s" % os.environ["TEST_CONF"])
    if CONFIG.white_box:
        report.log("")
        report.log("Test config file = %s" % rdl_config_file)
    report.log("")
    report.log("sys.path:")
    for path in sys.path:
        report.log("\t%s" % path)

    # Now that all configurations are loaded its time to import everything
    test_importer()

    atexit.register(_clean_up)

    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      plugins=core.DefaultPluginManager())
    runner = NovaTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c,
                            show_elapsed=show_elapsed,
                            known_bugs=CONFIG.known_bugs)
    MAIN_RUNNER = runner

    if repl:
        # Turn off the following "feature" of the unittest module in case
        # we want to start a REPL.
        sys.exit = lambda x: None

    proboscis.TestProgram(argv=nose_args,
                          groups=groups,
                          config=c,
                          testRunner=MAIN_RUNNER).run_and_exit()
    sys.stdout = sys.__stdout__
    sys.stderr = sys.__stderr__
コード例 #13
0
if __name__ == '__main__':
    exit_status = False

    # if a single test case was specified,
    # we should only invoked the tests once
    invoke_once = len(sys.argv) > 1

    test_config['plugin_name'] = "LinuxBridgePlugin.LinuxBridgePlugin"
    test_config['default_net_op_status'] = OperationalStatus.UP
    test_config['default_port_op_status'] = OperationalStatus.DOWN

    cwd = os.getcwd()
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      includeExe=True,
                      traverseNamespace=True,
                      plugins=core.DefaultPluginManager())
    c.configureWhere(quantum.tests.unit.__path__)
    exit_status = run_tests(c)

    if invoke_once:
        sys.exit(0)

    os.chdir(cwd)

    working_dir = os.path.abspath("quantum/plugins/linuxbridge")
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=working_dir)
コード例 #14
0
import os
import sys

from nose import config
from nose import core

sys.path.append(os.getcwd())
sys.path.append(os.path.dirname(__file__))

import ryu.tests.unit
from ryu.tests.test_lib import run_tests

if __name__ == '__main__':
    exit_status = False

    # if a single test case was specified,
    # we should only invoked the tests once
    invoke_once = len(sys.argv) > 1

    cwd = os.getcwd()
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=int(os.environ.get('NOSE_VERBOSE', 3)),
                      includeExe=True,
                      traverseNamespace=True,
                      plugins=core.DefaultPluginManager())
    c.configureWhere(ryu.tests.unit.__path__)

    exit_status = run_tests(c)
    sys.exit(exit_status)
コード例 #15
0
import os
import sys

from nose import config
from nose import core

sys.path.append(os.getcwd())
sys.path.append(os.path.dirname(__file__))

from quantum.common.test_lib import run_tests, test_config

if __name__ == '__main__':
    exit_status = False

    # if a single test case was specified,
    # we should only invoked the tests once
    invoke_once = len(sys.argv) > 1

    test_config['plugin_name'] = "meta_quantum_plugin.MetaPluginV2"

    cwd = os.getcwd()

    working_dir = os.path.abspath("quantum/plugins/metaplugin")
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=working_dir)
    exit_status = exit_status or run_tests(c)

    sys.exit(exit_status)
コード例 #16
0
        if self.show_elapsed:
            self._writeSlowTests(result_)
        return result_


if __name__ == '__main__':
    show_elapsed = True
    argv = []
    for x in sys.argv:
        if x.startswith('test_'):
            argv.append('nova.tests.%s' % x)
        elif x.startswith('--hide-elapsed'):
            show_elapsed = False
        else:
            argv.append(x)

    p = core.DefaultPluginManager()
    p.addPlugin(skipper.Skipper())

    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      plugins=p)

    runner = KongTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c,
                            show_elapsed=show_elapsed)

    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
コード例 #17
0
ファイル: __main__.py プロジェクト: eteq/astropysics
if __name__ == '__main__':
    from nose import run, config
    from nose.plugins import doctests, testid
    import os, sofatests

    print 'Running nose tests'
    cfg = config.Config(verbosity=2)
    run(config=cfg, plugins=[testid.TestId(), doctests.Doctest()])

    print 'Completed nose tests, running SOFA-based tests'
    if not os.path.abspath(os.curdir).endswith('tests'):
        os.chdir(os.path.join(os.curdir, 'tests'))
    sofatests.main(compile=True, epoch=None)