Ejemplo n.º 1
0
def runPythonUnitTests_(args, filterActions, testGroupName, testFiles):
    testArgs = ["dummy"]

    if args.testHarnessVerbose or args.list:
        testArgs.append('--nocapture')

    if args.loglevel:
        testArgs.append("--loglevel="+args.loglevel)

    if args.write_to_files:
        testArgs.append('--file')

    testArgs.append('--verbosity=0')

    if not args.list:
        print("Executing %s unit tests." % testGroupName)

    root_dir = os.path.dirname(os.path.abspath(__file__))

    testCapturePlugin = OutputCapturePlugin()

    plugins = nose.plugins.manager.PluginManager([testCapturePlugin])

    config = nose.config.Config(plugins=plugins)
    config.configure(testArgs)

    testCases = loadTestCases(config, testFiles, root_dir, '.')
    if args.mod_pair:
        n,m = args.mod_pair

        tests_to_keep = []
        for t in testCases:
            test_id = sum(ord(x) for x in t.id())
            if test_id % m == n:
                tests_to_keep.append(t)
        testCases = tests_to_keep
    if args.tests_from:
        with open(args.tests_from, "r") as f:
            test_list = [x.strip() for x in f.read().split("\n") if x.strip()]

        testsByName = {test.id(): test for test in testCases}

        testCases = [testsByName[t] for t in test_list]

    if filterActions:
        testCases = applyFilterActions(filterActions, testCases)

    if args.copies:
        testCases = testCases * args.copies

    if args.list:
        for test in testCases:
            print(test.id())

        os._exit(0)

    runPyTestSuite(config, None, testCases, testArgs)

    return testCapturePlugin.individualTestResults
Ejemplo n.º 2
0
def runPythonUnitTests_(args, testFilter, testGroupName, testFiles):
    testArgs = ["dummy"]

    if args.testHarnessVerbose or args.list:
        testArgs.append('--nocaptureall')

    testArgs.append('--verbosity=0')

    if not args.list:
        print "Executing %s unit tests." % testGroupName

    Setup.config().configureLoggingForUserProgram()

    parser = PythonTestArgumentParser()
    filterActions = parser.parse_args(args.remainder)

    bsaRootDir = os.path.split(ufora.__file__)[0]

    testCasesToRun = []

    plugins = nose.plugins.manager.PluginManager([OutputCaptureNosePlugin()])

    config = nose.config.Config(plugins=plugins)
    config.configure(testArgs)
    for i in range(args.copies):
        testCases = UnitTestCommon.loadTestCases(config, testFiles, bsaRootDir,
                                                 'ufora')
        if filterActions:
            testCases = applyFilterActions(filterActions, testCases)

        testCasesToRun += testCases

    if testFilter is not None:
        testCasesToRun = testFilter(testCasesToRun)

    if args.list:
        for test in testCasesToRun:
            print test.id()

        os._exit(0)

    if args.random:
        import random
        random.shuffle(testCasesToRun)

    if args.pythreadcheck:
        results = {}
        for test in testCasesToRun:
            results[test] = runPyTestSuite(config, None,
                                           unittest.TestSuite([test]),
                                           testArgs)

        return True in results.values()
    else:
        testFiles = '.'
        return runPyTestSuite(config, None, testCasesToRun, testArgs)
Ejemplo n.º 3
0
def nose_run():
    "Oh nose, why dost thou never read my configuration file"
    import nose.config
    config = nose.config.Config()
    config.configure(['--logging-level=DEBUG',
                      '--verbosity=3',      # why is this ignored?
                      # '--with-doctest=1', # not recognized?
                      #'--doctest-tests'
                      ])
    config.verbosity = 3
    nose.run(config=config)
Ejemplo n.º 4
0
def nose_run(module=None):
    import nose.config
    import __main__
    config = nose.config.Config()
    config.configure(['--logging-level=DEBUG',
                      '--verbosity=3',      # why is this ignored?
                      # '--with-doctest=1', # not recognized?
                      #'--doctest-tests'
                      ])
    config.verbosity = 3
    nose.run(module=module or __main__, config=config)
Ejemplo n.º 5
0
Archivo: test.py Proyecto: nkhuyu/ufora
def runPythonUnitTests_(args, testFilter, testGroupName, testFiles):
    testArgs = ["dummy"]

    if args.testHarnessVerbose or args.list:
        testArgs.append('--nocaptureall')

    testArgs.append('--verbosity=0')

    if not args.list:
        print "Executing %s unit tests." % testGroupName

    Setup.config().configureLoggingForUserProgram()

    parser = PythonTestArgumentParser()
    filterActions = parser.parse_args(args.remainder)

    bsaRootDir = os.path.split(ufora.__file__)[0]

    testCasesToRun = []

    plugins = nose.plugins.manager.PluginManager([OutputCaptureNosePlugin()])

    config = nose.config.Config(plugins=plugins)
    config.configure(testArgs)
    for i in range(args.copies):
        testCases = UnitTestCommon.loadTestCases(config, testFiles, bsaRootDir, 'ufora')
        if filterActions:
            testCases = applyFilterActions(filterActions, testCases)

        testCasesToRun += testCases

    if testFilter is not None:
        testCasesToRun = testFilter(testCasesToRun)

    if args.list:
        for test in testCasesToRun:
            print test.id()

        os._exit(0)

    if args.random:
        import random
        random.shuffle(testCasesToRun)

    if args.pythreadcheck:
        results = {}
        for test in testCasesToRun:
            results[test] = runPyTestSuite(config, None, unittest.TestSuite([test]), testArgs)

        return True in results.values()
    else:
        testFiles = '.'
        return runPyTestSuite(config, None, testCasesToRun, testArgs)
Ejemplo n.º 6
0
def runPythonUnitTests(args, filterActions, modules):
    testArgs = ["dummy"]

    if args.dump_native:
        import nativepython.runtime as runtime
        runtime.Runtime.singleton().verboselyDisplayNativeCode()

    if args.testHarnessVerbose or args.list:
        testArgs.append('--nocapture')

    if args.dumpFailureLogsToStdOut:
        testArgs.append('--dumpFailureLogsToStdOut')

    testArgs.append('--verbosity=0')

    testCasesToRun = []

    plugins = nose.plugins.manager.PluginManager([OutputCapturePlugin()])

    config = nose.config.Config(plugins=plugins)
    config.configure(testArgs)

    testCases = []
    for module in modules:
        dir = os.path.dirname(module.__file__)
        testCases += loadTestCases(config, findTestFiles(dir, '.*_test.py$'),
                                   os.path.dirname(dir))

    if filterActions:
        testCases = applyFilterActions(filterActions, testCases)

    testCasesToRun += testCases

    if args.list:
        for test in testCasesToRun:
            print(test.id())

        os._exit(0)

    return runPyTestSuite(config, None, testCasesToRun, testArgs)