示例#1
0
def run_pytest(module_tests, tests, verbosity, extra_arg_groups):
    from pytest import main

    # parse test name, e.g.
    #   "rez.tests.test_solver.TestSolver.test_01"
    # into
    #   "test_solver.py::TestSolver::test_01"
    test_specifications = []
    for test in tests:
        specifier = ""
        for part in test.split("."):
            if specifier:
                specifier += "::" + part
                continue
            if os.path.isfile(part + ".py"):
                specifier = part + ".py"
        if specifier:
            test_specifications.append(specifier)

    module_tests = [("test_%s.py" % x) for x in sorted(module_tests)]
    tests = module_tests + test_specifications

    argv = tests[:]

    if verbosity:
        argv += ["-" + ("v" * verbosity)]
    if extra_arg_groups:
        argv += extra_arg_groups[0]

    main(args=argv)
示例#2
0
def run_unittest(module_tests, tests, verbosity):
    from unittest.main import main

    module_tests = [("rez.tests.test_%s" % x) for x in sorted(module_tests)]
    tests = module_tests + tests

    argv = [sys.argv[0]] + tests
    main(module=None, argv=argv, verbosity=verbosity)
示例#3
0
def run():
    global __unittest

    if sys.argv[0].endswith("__main__.py"):
        sys.argv[0] = "python -m unittest"
    __unittest = True
    from unittest.main import main, TestProgram, USAGE_AS_MAIN

    TestProgram.USAGE = USAGE_AS_MAIN
    main(module=None)
示例#4
0
def run():
    global __unittest

    if sys.argv[0].endswith("__main__.py"):
        sys.argv[0] = "python -m unittest"
    __unittest = True
    from unittest.main import main, TestProgram, USAGE_AS_MAIN

    TestProgram.USAGE = USAGE_AS_MAIN
    main(module=None)
示例#5
0
def run():
    global __unittest

    if sys.argv[0].endswith("__main__.py"):
        sys.argv[0] = "python -m unittest"
    __unittest = True

    # Support for python version >= 3.4
    if sys.hexversion >= 0x030400F0:
        from unittest.main import main
    else:
        from unittest.main import main, TestProgram, USAGE_AS_MAIN
        TestProgram.USAGE = USAGE_AS_MAIN

    main(module=None)
示例#6
0
def run():
    global __unittest

    if sys.argv[0].endswith("__main__.py"):
        sys.argv[0] = "python -m unittest"
    __unittest = True

    # Support for python version >= 3.4
    if sys.hexversion >= 0x030400F0:
        from unittest.main import main
    else:
        from unittest.main import main, TestProgram, USAGE_AS_MAIN
        TestProgram.USAGE = USAGE_AS_MAIN

    main(module=None)
示例#7
0
def command(opts, parser, extra_arg_groups=None):
    import sys
    from unittest.main import main

    os.environ["__REZ_SELFTEST_RUNNING"] = "1"

    if opts.only_shell:
        os.environ["__REZ_SELFTEST_SHELL"] = opts.only_shell

    if not opts.module_tests and not opts.tests:
        module_tests = all_module_tests
    else:
        module_tests = opts.module_tests
    module_tests = [("rez.tests.test_%s" % x) for x in sorted(module_tests)]
    tests = module_tests + opts.tests

    argv = [sys.argv[0]] + tests
    main(module=None, argv=argv, verbosity=opts.verbose)
示例#8
0
from unittest.main import main

if __name__ == '__main__':
	main(module=None, verbosity=2)
示例#9
0
#!/usr/bin/env python
import xmlrunner

__unittest = True

from unittest.main import main, TestProgram, USAGE_AS_MAIN
TestProgram.USAGE = USAGE_AS_MAIN

main(module=None, verbosity=2, testRunner=xmlrunner.XMLTestRunner(output='test-results'), failfast=False, buffer=False, catchbreak=False)
示例#10
0
#!/usr/bin/python
'''Script for running unittest discovery with an XMLTestRunner for reporting
This is the equivalent of running: python -m unittest discover
'''

import xmlrunner
from optparse import OptionParser

__unittest = True

from unittest.main import main, TestProgram, USAGE_AS_MAIN
TestProgram.USAGE = USAGE_AS_MAIN


parser = OptionParser()
parser.add_option('-x', '--xml-report', dest='xml_report', action='store_true', default=False, help='enable XMLTestRunner')

options, args = parser.parse_args()

if options.xml_report:
    test_runner = xmlrunner.XMLTestRunner(output='test/test-reports')
    print 'Running tests with XMLTestRunner'
else:
    test_runner = None


main(module=None, argv=['foo', 'discover'], testRunner=test_runner) 
示例#11
0
def test_specific_test():
    sys.argv = ['TEST']
    sys.argv.append('test_asynctestcase.TestAsyncCase.test_await_async_add')
    a = main(module=None, exit=False)
示例#12
0
        (handler,), _ = add_handler.call_args
        self.assertIsInstance(handler, logging.StreamHandler)

        self.assertEqual(handler.level, settings["LOG_LEVEL"])
        self.assertEqual(handler.formatter.datefmt, settings["LOG_FORMATTER_DATEFMT"])
        self.assertEqual(handler.formatter._fmt, settings["LOG_FORMATTER_FMT"])

    def test_get_runtime_info(self) -> None:
        """

        :return:
        :rtype: None
        """
        logger = logging.getLogger("test")
        with self.assertLogs("test", level=logging.INFO) as logs_cm:
            get_runtime_info(logger)

        self.assertSequenceEqual(
            [x.msg for x in logs_cm.records],
            [
                "Platform: %(platform)s",
                "Platform details:\n%(details)s",
                "Versions:\n%(versions)s",
            ],
        )


if __name__ == "__main__":
    main()
示例#13
0
文件: setup.py 项目: ma-ric/pymarkups
	def run(self):
		from unittest.main import main
		testprogram = main(module=None, argv=sys.argv[:1], verbosity=2, exit=False)
		if not testprogram.result.wasSuccessful():
			sys.exit(1)
    def addError(self, test, err):
        super().addError(test, err)
        sys.stdout.write_msg("ERROR\n")

    def addFailure(self, test, err):
        super().addError(test, err)
        sys.stdout.write_msg("FAIL\n")

    def printErrors(self):
        sys.stdout.set_preambule("")
        print()
        self.printErrorList('ERROR', self.errors)
        self.printErrorList('FAIL', self.failures)

    def printErrorList(self, flavour, errors):
        for test, err in errors:
            print(self.separator1)
            print("%s: %s" % (flavour, self.getDescription(test)))
            print(self.separator2)
            print("%s" % err)


_stdout = sys.stdout
sys.stderr = sys.stdout = PreambuleStream()

testRunner = TextTestRunner(resultclass=QuietTestResult,
                            stream=sys.stdout,
                            verbosity=2)

main(module=None, testRunner=testRunner)
示例#15
0
"""Main entry point"""

import sys

from unittest.main import main, TestProgram, USAGE_AS_MAIN
from .runner import TAPTestRunner

if sys.argv[0].endswith("__main__.py"):
    sys.argv[0] = "python3 -m simpletap"

__unittest = True

TestProgram.USAGE = USAGE_AS_MAIN

main(module=None, testRunner=TAPTestRunner())
示例#16
0
    # We change sys.argv[0] to make help message more useful
    # use executable without path, unquoted
    # (it's just a hint anyway)
    # (if you have spaces in your executable you get what you deserve!)
    executable = os.path.basename(sys.executable)
    sys.argv[0] = executable + " -m unittest"
    del os

__unittest = True

from unittest.main import main

if HAVE_COVERAGE:
    html_dir = 'test_coverage'
    cov = coverage.Coverage(branch=True)
    cov._warn_no_data = False
    cov.exclude(r'\@abc\.abstract', 'partial')
    cov.start()

try:
    main(module=None, exit=False)
except:
    raise
finally:
    if HAVE_COVERAGE:
        cov.stop()
        cov.save()
        cov.html_report(
            directory=html_dir,
            title='DapGen test coverage')
示例#17
0
"""Main entry point"""

import sys

from unittest.main import main, TestProgram, USAGE_AS_MAIN
from .runner import TAPTestRunner


if sys.argv[0].endswith("__main__.py"):
    sys.argv[0] = "python3 -m simpletap"

__unittest = True

TestProgram.USAGE = USAGE_AS_MAIN

main(module=None, testRunner=TAPTestRunner())
示例#18
0
        get_oneflow_cpu_kernel_time(profs[2]),
        get_oneflow_cpu_end_to_end_time(profs[2]),
        additional_description,
    ])
    writer.writerow([
        op_name,
        args_description,
        "PyTorch",
        get_pytorch_gpu_kernel_time(profs[3]),
        "-",
        get_pytorch_cpu_kernel_time(profs[4]),
        get_pytorch_cpu_end_to_end_time(profs[4]),
        get_pytorch_cpu_kernel_time(profs[5]),
        get_pytorch_cpu_end_to_end_time(profs[5]),
        additional_description,
    ])
    f.flush()


auto_profiler.set_profiler_hook(add_row)

# Align with https://github.com/python/cpython/blob/3.10/Lib/unittest/__main__.py
__unittest = True

from unittest.main import main

loader = unittest.TestLoader()
loader.testMethodPrefix = "profile_"

main(module=None, testLoader=loader)
示例#19
0
#!/usr/bin/env python3

from unittest.main import main

if __name__ == '__main__':
    main(module=None)
示例#20
0
#!/usr/bin/env python
import sys
import xmlrunner

__unittest = True

from unittest.main import main
main(module=None, testRunner=xmlrunner.XMLTestRunner())
示例#21
0
#!/usr/bin/env python3

from unittest.main import main

if __name__ == "__main__":
    main(module=None)
'''Script for running unittest discovery with an XMLTestRunner for reporting
This is the equivalent of running: python -m unittest discover
'''

import xmlrunner
from optparse import OptionParser

__unittest = True

from unittest.main import main, TestProgram, USAGE_AS_MAIN

TestProgram.USAGE = USAGE_AS_MAIN

parser = OptionParser()
parser.add_option('-x',
                  '--xml-report',
                  dest='xml_report',
                  action='store_true',
                  default=False,
                  help='enable XMLTestRunner')

options, args = parser.parse_args()

if options.xml_report:
    test_runner = xmlrunner.XMLTestRunner(output='test/test-reports')
    print 'Running tests with XMLTestRunner'
else:
    test_runner = None

main(module=None, argv=['foo', 'discover'], testRunner=test_runner)