예제 #1
0
def main(argv):  # 主方法
    pattern = 'test_*.py'   # pattern默认搜集全部测试用例
    env = 'test'  # 默认在测试环境运行测试用例
    try:
        opts, args = getopt.getopt(argv, 'hp:e:')
        for opt, arg in opts:
            if opt == '-h':
                print('run.py -p <pattern> -e <environment>')
                sys.exit()
            if opt == '-e':
                env = arg.lower()
            if opt == '-p':
                pattern = f'{arg}*.py'

        build_config(env)  # 构建CONFIG文件
    except getopt.GetoptError as e:
        print(e)
        sys.exit()

    # 根据入参pattern,在case文件夹中收集测试用例,pattern默认搜集全部测试用例
    cases = defaultTestLoader.discover('./case/', pattern=pattern)

    # 实例化一个测试执行器并执行所有测试用例
    runner = TextTestRunner()
    runner.run(cases)
예제 #2
0
def _unittests():
    from unittest import TestSuite, defaultTestLoader, TextTestRunner
    _tests = TestSuite()
    for case in defaultTestLoader.discover('.', 'test_*.py'):
        _tests.addTests(case)
    tester = TextTestRunner()
    tester.run(_tests)
예제 #3
0
def Entry():
    args = {"-m": None, "-utest": False}

    if len(sys.argv) > 1:
        for i in range(len(sys.argv)):
            args[sys.argv[i]] = Switch(sys.argv[i], {
            "-m": lambda: LoadFile(sys.argv[i + 1]),
            "-utest": lambda: True,
            "-help": lambda: ListAllCmds()
            })

    symbolTable = args["-m"]

    if args["-utest"]:
        sys.argv.pop()

        suite = RunTest()
        testRunner = TextTestRunner()
        testRunner.run(suite)

        return EXIT_SUCCESS

    sys.setrecursionlimit(2000)
    Interactive(symbolTable)
        
    return EXIT_SUCCESS
예제 #4
0
def run_tests():
    suite = TestSuite()
    suite.addTest(TestRAVerification('test_verify_prefix'))
    suite.addTest(TestRAVerification('test_verify_cert'))
    suite.addTest(TestRAVerification('test_verify_signature'))
    runner = TextTestRunner()
    runner.run(suite)
예제 #5
0
    def run(self, suite_name=None, testcase_name=None):

        def run_app(app):
            from werkzeug.serving import run_simple
            run_simple('127.0.0.1', 5000, app)

        app_thread = threading.Thread(target=run_app, args=(self.app, ))
        app_thread.setDaemon(True)
        app_thread.start()

        runner = TextTestRunner()

        for suite in self.testsuites:
            if suite_name is None or suite.name == suite_name:

                if testcase_name is not None:
                    testcase = self.get_runnable_testcase_with_name_from_suite(testcase_name, suite)
                    if testcase is None:
                        return
                    print "Running testcase %s.%s" % (suite_name, testcase_name)
                    runner.run(testcase)
                    break
                else:
                    suite.init_test_instances(self)
                    runner.run(suite)

        self.remove_db_file()
예제 #6
0
 def run(self):
     sys.path.insert(0, os.path.join(self._dir, BOKEEP_SRC_DIR) )
     sys.path.insert(0, os.path.join(self._dir, 'tests') )
     tests = list(self.generate_test_files())
     tests = TestLoader().loadTestsFromNames( tests )
     t = TextTestRunner(verbosity = 1)
     t.run(tests)
예제 #7
0
def test_all():

    loader = TestLoader()
    suite = TestSuite((loader.loadTestsFromTestCase(MongoTest)))

    runner = TextTestRunner(verbosity=2)
    runner.run(suite)
예제 #8
0
    def run(self):
       '''
       Finds all the tests modules in tests/, and runs them, exiting after they are all done
       '''
       from tests.testserver import TestServer
       from tests.test import WebserviceTest

       log.set_verbosity(self.verbose)

       server = TestServer()
       server.start()
       WebserviceTest.TEST_PORT = server.port

       self.announce("Waiting for test server to start on port " + str(server.port), level=2)
       time.sleep(1)

       testfiles = [ ]
       for t in glob(pjoin(self._dir, 'tests', self.test_prefix + '*.py')):
           if not t.endswith('__init__.py'):
               testfiles.append('.'.join(
                   ['tests', splitext(basename(t))[0]])
               )

       self.announce("Test files:" + str(testfiles), level=2)
       tests = TestLoader().loadTestsFromNames(testfiles)
       t = TextTestRunner(verbosity = self.verbose)
       t.run(tests)
       exit()
예제 #9
0
파일: setup.py 프로젝트: mac0ne/pythran
    def run(self):
        # Do not include current directory, validate using installed pythran
        current_dir = _exclude_current_dir_from_import()
        os.chdir("pythran/tests")
        where = os.path.join(current_dir, 'pythran')

        from pythran import test_compile
        test_compile()

        try:
            import py
            import xdist
            args = ["-n", str(self.num_threads), where, '--pep8']
            if self.failfast:
                args.insert(0, '-x')
            if self.cov:
                try:
                    import pytest_cov
                    args = ["--cov-report", "html",
                            "--cov-report", "annotate",
                            "--cov", "pythran"] + args
                except ImportError:
                    print ("W: Skipping coverage analysis, pytest_cov"
                           "not found")
            if py.test.cmdline.main(args) == 0:
                print "\\_o<"
        except ImportError:
            print ("W: Using only one thread, "
                   "try to install pytest-xdist package")
            loader = TestLoader()
            t = TextTestRunner(failfast=self.failfast)
            t.run(loader.discover(where))
            if t.wasSuccessful():
                print "\\_o<"
예제 #10
0
파일: setup.py 프로젝트: pricez/rfc3161
 def run(self):
     '''
     Finds all the tests modules in tests/, and runs them.
     '''
     tests = TestLoader().loadTestsFromName('tests.api')
     t = TextTestRunner(verbosity = 1)
     t.run(tests)
예제 #11
0
 def run(self):
     sys.path.insert(0, os.path.join(root_dir, package_dir))
     sys.path.insert(0, os.path.join(root_dir, test_dir))
     os.chdir(test_dir)
     import all_tests
     t = TextTestRunner(verbosity=2)
     t.run(all_tests.suite())
예제 #12
0
파일: setup.py 프로젝트: waiebank/intermine
    def run(self):
        '''
       Finds all the tests modules in tests/, and runs them, exiting after they are all done
       '''
        from tests.testserver import TestServer
        from tests.test import WebserviceTest

        log.set_verbosity(self.verbose)

        server = TestServer()
        server.start()
        WebserviceTest.TEST_PORT = server.port

        self.announce("Waiting for test server to start on port " +
                      str(server.port),
                      level=2)
        time.sleep(1)

        testfiles = []
        for t in glob(pjoin(self._dir, 'tests', self.test_prefix + '*.py')):
            if not t.endswith('__init__.py'):
                testfiles.append('.'.join(['tests', splitext(basename(t))[0]]))

        self.announce("Test files:" + str(testfiles), level=2)
        tests = TestLoader().loadTestsFromNames(testfiles)
        t = TextTestRunner(verbosity=self.verbose)
        t.run(tests)
        exit()
예제 #13
0
def run_tests():
    suite = TestSuite()
    suite.addTest(TestRAVerification('test_verify_prefix'))
    suite.addTest(TestRAVerification('test_verify_cert'))
    suite.addTest(TestRAVerification('test_verify_signature'))
    runner = TextTestRunner()
    runner.run(suite)
예제 #14
0
 def run(self):
     """
     Finds and executes unit tests in the 'tests' subdir.
     Because TestLoader imports the tests as a module this method
     automatically creates/updates the 'tests/__init__.py' to
     import all python scripts in the 'tests' subdir.
     """
     self.run_command('build')
     sys.path.insert(0,os.path.join(os.getcwd(),"build","lib"))
     self.tests  = []
     # make sure the 'tests' subdir actually exists.
     if not os.path.isdir(self.tests_dir):
         print "ExecuteTests: <Error> 'tests' subdir not found!"
     else:
         self.find_tests()
         self.gen_tests_init()
         # create a test suite.
         tests = TestLoader().loadTestsFromNames([t[0] for t in self.tests])
         if not self.filter is None:
             tests = self.filter_tests(tests)
         # run the test suite if it actually contains test cases.
         run_verbosity = 2
         if self.verbose == 0:
             run_verbosity = 0
         if tests.countTestCases() > 0:
             runner = TextTestRunner(verbosity=run_verbosity)
             runner.run(tests)
         else:
             print "ExecuteTests: <Warning> No test cases found!"
     sys.path.pop(0)
예제 #15
0
파일: setup.py 프로젝트: baoboa/pythran
    def run(self):
        # Do not include current directory, validate using installed pythran
        current_dir = _exclude_current_dir_from_import()
        os.chdir("pythran/tests")
        where = os.path.join(current_dir, 'pythran')

        from pythran import test_compile
        test_compile()

        try:
            import py
            import xdist
            args = ["-n", str(self.num_threads), where, '--pep8']
            if self.failfast:
                args.insert(0, '-x')
            if self.cov:
                try:
                    import pytest_cov
                    args = ["--cov-report", "html",
                            "--cov-report", "annotate",
                            "--cov", "pythran"] + args
                except ImportError:
                    print ("W: Skipping coverage analysis, pytest_cov"
                           "not found")
            if py.test.cmdline.main(args) == 0:
                print "\\_o<"
        except ImportError:
            print ("W: Using only one thread, "
                   "try to install pytest-xdist package")
            loader = TestLoader()
            t = TextTestRunner(failfast=self.failfast)
            t.run(loader.discover(where))
            if t.wasSuccessful():
                print "\\_o<"
예제 #16
0
def main():
    suite = TestSuite()
    suite.addTest(ParserTest("test_parser"))
    suite.addTest(DirectiveTestDate("test_regexp"))
    suite.addTest(DirectiveTestDate("test_format"))
    runner = TextTestRunner()
    runner.run(suite)
예제 #17
0
    def run(self):
        '''
        Runs all unit tests
        '''
        testfiles = []
        all_testfiles = glob(pjoin(self._dir, 'tests', '*.py'))
        excluded_files = [
            '__init__.py',
            'katparser.py',
        ]

        # Skip the extremelylongtests
        #excluded_files.append('test_extremelylonkat.py']
        excluded_files.append('test_extremelylong_similar.py')

        excluded_files_full_path = []
        for f in excluded_files:
            excluded_files_full_path.append(pjoin(self._dir, 'tests', f))

        for f in all_testfiles:
            if f not in excluded_files_full_path:
                testfiles.append('.'.join(['tests', splitext(basename(f))[0]]))

        tests = TestLoader().loadTestsFromNames(testfiles)
        t = TextTestRunner(verbosity=3)
        t.run(tests)
예제 #18
0
파일: run_test.py 프로젝트: txu2k8/libs-py
def main():
    """Main method
    """
    args = parse_arg()
    command = 'python ' + ' '.join(sys.argv)

    logger.info('Test args:\n{0}'.format(args))
    logger.info("Test command:\n{cmd}".format(cmd=command))

    # -----------------------------
    # --- Run unittest suite
    # -----------------------------
    if args.runner == 'TextTestRunner':
        # run with TextTestRunner
        from unittest import TextTestRunner
        runner = TextTestRunner(verbosity=2)
    else:
        # run with StressRunner -- report html
        # run with StressRunner -- report html
        runner = StressRunner(
            report_path=REPORT_PATH,
            title='My unit test',
            description='This demonstrates the report output by StressRunner.',
            logger=logger)

    # get unittest test suite and then run unittest case
    test_suite = args.func(args)
    runner.run(test_suite)

    return True
예제 #19
0
 def run(self):
     """
     Finds and executes unit tests in the 'tests' subdir.
     Because TestLoader imports the tests as a module this method
     automatically creates/updates the 'tests/__init__.py' to
     import all python scripts in the 'tests' subdir.
     """
     self.run_command('build')
     sys.path.insert(0, os.path.join(os.getcwd(), "build", "lib"))
     self.tests = []
     # make sure the 'tests' subdir actually exists.
     if not os.path.isdir(self.tests_dir):
         print "ExecuteTests: <Error> 'tests' subdir not found!"
     else:
         self.find_tests()
         self.gen_tests_init()
         # create a test suite.
         tests = TestLoader().loadTestsFromNames([t[0] for t in self.tests])
         if not self.filter is None:
             tests = self.filter_tests(tests)
         # run the test suite if it actually contains test cases.
         run_verbosity = 2
         if self.verbose == 0:
             run_verbosity = 0
         if tests.countTestCases() > 0:
             runner = TextTestRunner(verbosity=run_verbosity)
             runner.run(tests)
         else:
             print "ExecuteTests: <Warning> No test cases found!"
     sys.path.pop(0)
예제 #20
0
파일: setup.py 프로젝트: franckCJ/pythran
 def run(self):
     where = os.path.join('pythran', 'tests')
     try:
         import py
         import xdist
         import multiprocessing
         cpu_count = multiprocessing.cpu_count()
         args = ["-n", str(cpu_count), where]
         if self.failfast:
             args.insert(0, '-x')
         if self.cov:
             try:
                 import pytest_cov
                 args = ["--cov-report", "html",
                         "--cov-report", "annotate",
                         "--cov", "pythran"] + args
             except ImportError:
                 print ("W: Skipping coverage analysis, pytest_cov"
                         "not found")
         py.test.cmdline.main(args)
     except ImportError:
         print ("W: Using only one thread, "
                 "try to install pytest-xdist package")
         loader = TestLoader()
         t = TextTestRunner(failfast=self.failfast)
         t.run(loader.discover(where))
예제 #21
0
 def run(self):
     import os
     from unittest import TestLoader, TextTestRunner
     cur_dir = os.path.dirname(os.path.abspath(__file__))
     loader = TestLoader()
     test_suite = loader.discover(cur_dir)
     runner = TextTestRunner(verbosity=2)
     runner.run(test_suite)
예제 #22
0
 def run(self):
     import os
     from unittest import TestLoader, TextTestRunner
     cur_dir = os.path.dirname(os.path.abspath(__file__))
     loader = TestLoader()
     test_suite = loader.discover(cur_dir)
     runner = TextTestRunner(verbosity=2)
     runner.run(test_suite)
예제 #23
0
 def run(self):
     '''
     Finds all the tests and runs them.
     '''
     base = dirname(__file__)
     tests = TestLoader().discover(base)
     t = TextTestRunner(verbosity = 4)
     t.run(tests)
예제 #24
0
def run():
    loader = TestLoader()
    suite = TestSuite((
        loader.loadTestsFromTestCase(UtilsTests),
        loader.loadTestsFromTestCase(Tests)
    ))
    runner = TextTestRunner(verbosity = 2)
    runner.run(suite)
예제 #25
0
def callback(item):

    print "Catch the modification of '{0}'".format(item.path)
    test_path = os.path.join(os.path.dirname(__file__), '../tests')
    test_loader = loader.TestLoader()
    testrunner = TextTestRunner(verbosity=2)
    testrunner.run(test_loader.discover(test_path))
    print "=" * 80
def run_suite(verbose=False):
    loader = TestLoader()
    runner = TextTestRunner(verbosity=2 if verbose else 1)
    suite = TestSuite()
    for mod in get_modules():
        suite.addTest(loader.loadTestsFromModule(mod))
    runner.run(suite)
    return 0
예제 #27
0
def run_tests(testfiles=None, cwd=None, verbosity=None):
    if testfiles is None:
        testfiles = get_testfiles(cwd=cwd)
    if verbosity is None:
        verbosity = 1
    tests = TestLoader().loadTestsFromNames(testfiles)
    t = TextTestRunner(verbosity=verbosity)
    t.run(tests)
예제 #28
0
def run_suite(verbose=False):
    loader = TestLoader()
    runner = TextTestRunner(verbosity=2 if verbose else 1)
    suite = TestSuite()
    for mod in get_modules():
        suite.addTest(loader.loadTestsFromModule(mod))
    runner.run(suite)
    return 0
예제 #29
0
파일: test.py 프로젝트: kmshi/miroguide
def main(args):
    parse_args(args)
    logging.getLogger('').addHandler(TestLogHandler())
    tests = load_tests()
    runner = TextTestRunner()
    if options.verbose:
        runner.verbosity = 2
    runner.run(tests)
예제 #30
0
파일: test.py 프로젝트: kmshi/miroguide
def main(args):
    parse_args(args)
    logging.getLogger('').addHandler(TestLogHandler())
    tests = load_tests()
    runner = TextTestRunner()
    if options.verbose:
        runner.verbosity = 2
    runner.run(tests)
예제 #31
0
def run_tests(suite):
    if suite == 'dev':
        suite = TestSuite(data_tests)
    elif suite == 'prod' or suite == 'all':
        suite = loader.discover(os.path.dirname(TEST_DIR))

    runner = TextTestRunner(verbosity=3)
    runner.run(suite)
예제 #32
0
파일: test.py 프로젝트: Shraa/IceCharts
def main():
    loader = TestLoader()
    tests = [
        loader.loadTestsFromTestCase(test)
        for test in (TestGridService, TestGridsService, TestCellsService)
    ]
    suite = TestSuite(tests)
    runner = TextTestRunner(verbosity=2)
    runner.run(suite)
예제 #33
0
    def run(self):
        testfiles = []
        for t in glob(pjoin(self._dir, 'tests', '*.py')):
            if not t.endswith('__init__.py'):
                testfiles.append('.'.join(['tests', splitext(basename(t))[0]]))

        tests = TestLoader().loadTestsFromNames(testfiles)
        t = TextTestRunner(verbosity=1)
        t.run(tests)
예제 #34
0
def unittest():
    """
    Runs all unit tests using test discovery.
    """
    loader = TestLoader()
    suite = loader.discover(join(getcwd(), "tests"), pattern="*.py")

    runner = TextTestRunner(verbosity=2)
    runner.run(suite)
예제 #35
0
 def run(self):
     """Run test suite in BarNone.tests"""
     try:
         from BarNone import tests
     except ImportError:
         raise Exception("BarNone is not installed, cannot run tests")
     tests = TestLoader().loadTestsFromNames(["BarNone.tests"])
     t = TextTestRunner(verbosity=1)
     t.run(tests)
예제 #36
0
    def run(self):
        testfiles = []
        for t in glob(pjoin(self._dir, "tests", "*.py")):
            if not t.endswith("__init__.py"):
                testfiles.append(".".join(["tests", splitext(basename(t))[0]]))

        tests = TestLoader().loadTestsFromNames(testfiles)
        t = TextTestRunner(verbosity=1)
        t.run(tests)
예제 #37
0
def run_tests():
    """ Get plogs test suite and run all tests """

    # create test suite
    test_suite = create_test_suite()

    # run test suite
    test_runner = TextTestRunner(verbosity=2)
    test_runner.run(test_suite)
예제 #38
0
파일: setup.py 프로젝트: dgrtwo/BarNone
 def run(self):
     """Run test suite in BarNone.tests"""
     try:
         from BarNone import tests
     except ImportError:
         raise Exception("BarNone is not installed, cannot run tests")
     tests = TestLoader().loadTestsFromNames(["BarNone.tests"])
     t = TextTestRunner(verbosity=1)
     t.run(tests)
예제 #39
0
    def run(self):
        address = self.address or 'localhost:10190'

        os.environ.setdefault('URLFETCH_ADDR', address)
        import pyurlfetch.tests

        loader = TestLoader()
        t = TextTestRunner()
        t.run(loader.loadTestsFromModule(pyurlfetch.tests))
예제 #40
0
파일: setup.py 프로젝트: minrk/checkbuffers
 def run(self):
     """Finds all the tests modules in zmq/tests/, and runs them."""
     testfiles = []
     for t in glob(pjoin(self._dir, "checkbuffers", "tests", "*.py")):
         if not t.endswith("__init__.py"):
             testfiles.append(".".join(["checkbuffers.tests", splitext(basename(t))[0]]))
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity=1)
     t.run(tests)
예제 #41
0
def run_with_text_test_runner(args):
    """Run with TextTestRunner"""
    from unittest import TextTestRunner

    _logger = init_test_session(args)
    runner = TextTestRunner(verbosity=2)

    # get unittest test suite and then run unittest case
    test_suite, _ = args.func(args)
    runner.run(test_suite)
예제 #42
0
def R_unittests():
    # -- build test suite, adopted from https://docs.python.org/3/library/unittest.html#load-tests-protocol
    suite = TestSuite()
    loader = TestLoader()
    runner = TextTestRunner()
    tests = loader.loadTestsFromNames(RE_TEST_CASES)
    suite.addTests(tests)
    # -- run the suite
    #    this will print any failures in stderr
    runner.run(suite)
예제 #43
0
파일: setup.py 프로젝트: zathras777/vpcc
 def run(self):
     testfiles = []
     for poss_fn in os.listdir(os.path.join(self._dir, 'tests')):
         if not poss_fn.endswith('_test.py'):
             continue
         testfiles.append('.'.join(['tests', 
                                    os.path.splitext(poss_fn)[0]]))
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity=self.verbose)
     t.run(tests)
예제 #44
0
파일: setup.py 프로젝트: twosixlabs/pyzmq
 def run_unittest(self):
     """Finds all the tests modules in zmq/tests/ and runs them."""
     testfiles = []
     for t in glob(pjoin(self._dir, 'zmq', 'tests', '*.py')):
         name = splitext(basename(t))[0]
         if name.startswith('test_'):
             testfiles.append('.'.join(['zmq.tests', name]))
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity=2)
     t.run(tests)
예제 #45
0
파일: setup.py 프로젝트: underrun/pyzmq
 def run_unittest(self):
     """Finds all the tests modules in zmq/tests/ and runs them."""
     testfiles = []
     for t in glob(pjoin(self._dir, "zmq", "tests", "*.py")):
         name = splitext(basename(t))[0]
         if name.startswith("test_"):
             testfiles.append(".".join(["zmq.tests", name]))
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity=2)
     t.run(tests)
예제 #46
0
 def run(self):
     """Finds all the tests modules in zmq/tests/, and runs them."""
     testfiles = []
     for t in glob(pjoin(self._dir, 'zmq', 'tests', '*.py')):
         if not t.endswith('__init__.py'):
             testfiles.append('.'.join(
                 ['zmq.tests', splitext(basename(t))[0]]))
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity=1)
     t.run(tests)
예제 #47
0
def testAll():

    test_cases = [TestZ, TestZModRing, TestZModField, TestZX]

    suite = TestSuite()
    for case in test_cases:
        suite.addTests(defaultTestLoader.loadTestsFromTestCase(case))

    runner = TextTestRunner()
    runner.run(suite)
예제 #48
0
 def run(self):
     """
     Finds all the tests modules in tests/, and runs them.
     """
     testfiles = [ ]
     for t in filter(lambda f: not f.endswith('__init__.py'), glob(join(self._dir, 'tests', '*.py'))):
         testfiles.append('.'.join(['tests', splitext(basename(t))[0]]))
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity = 1)
     t.run(tests)
예제 #49
0
파일: test.py 프로젝트: KentaYamada/siphon
def run():
    # switch test config
    environ['APP_TYPE'] = 'test'
    config = get_config()

    paths = (config.TEST_ROOT_DIR, )
    loader = TestLoader()
    for p in paths:
        tests = loader.discover(p)
        runner = TextTestRunner()
        runner.run(tests)
예제 #50
0
파일: setup.py 프로젝트: libscott/pyzmq
 def run(self):
     """Finds all the tests modules in zmq/tests/, and runs them."""
     testfiles = [ ]
     for t in glob(pjoin(self._dir, 'zmq', 'tests', '*.py')):
         if not t.endswith('__init__.py'):
             testfiles.append('.'.join(
                 ['zmq.tests', splitext(basename(t))[0]])
             )
     tests = TestLoader().loadTestsFromNames(testfiles)
     t = TextTestRunner(verbosity = 2)
     t.run(tests)
예제 #51
0
파일: setup.py 프로젝트: vkuznet/Skeletons
 def run(self):
     "Finds all the tests modules in tests/, and runs them"
     # list of files to exclude,
     # e.g. [pjoin(self._dir, 'tests', 'exclude_t.py')]
     exclude = []
     # list of test files
     testfiles = []
     for tname in glob(pjoin(self._dir, 'tests', '*_t.py')):
         if  not tname.endswith('__init__.py') and \
             tname not in exclude:
             testfiles.append('.'.join(
                 ['tests', splitext(basename(tname))[0]])
             )
     testfiles.sort()
     try:
         tests = TestLoader().loadTestsFromNames(testfiles)
     except:
         print "Fail to load unit tests", testfiles
         raise
     test = TextTestRunner(verbosity = 2)
     test.run(tests)
     # run integration tests
     print "run integration tests"
     cdir = os.getcwd()
     base = os.path.join(os.getcwd(), 'int_tests')
     wdir = os.path.join(base, 'src/SubSystem')
     sdir = os.path.join(os.getcwd(), 'scripts')
     tdir = os.path.join(sdir, 'mkTemplates')
     os.environ['CMSSW_BASE'] = base
     if  os.path.isdir(base):
         shutil.rmtree(base)
     os.makedirs(wdir)
     os.chdir(wdir)
     for pkg in os.listdir(tdir):
         if  pkg == 'c++11':
             test_pkg = 'Mycpp'
         else:
             test_pkg = 'My%s' % pkg
         script = find_script(sdir, pkg)
         if  script.find('mktmpl') != -1:
             cmd = '%s/%s --name=%s' % (sdir, script, test_pkg)
         else:
             cmd = '%s/%s %s' % (sdir, script, test_pkg)
         print '\n###', cmd
         subprocess.call(cmd, shell=True)
         if  pkg in ['Record', 'Skeleton']:
             for fname in os.listdir(os.getcwd()):
                 os.remove(fname)
         else:
             shutil.rmtree(test_pkg)
     if  os.path.isdir(base):
         shutil.rmtree(base)
     os.chdir(cdir)
예제 #52
0
파일: setup.py 프로젝트: bjcohen/python-lzw
    def run(self):
        import lzw
        doctest.testmod(lzw)

        utests = defaultTestLoader.loadTestsFromName(TEST_MODULE_NAME)
        urunner = TextTestRunner(verbosity=2)
        urunner.run(utests)

        if self.runslow:
            utests = defaultTestLoader.loadTestsFromName(SLOW_TEST_MODULE_NAME)
            urunner = TextTestRunner(verbosity=2)
            urunner.run(utests)
예제 #53
0
 def run(self):
     """Finds all the tests modules in tests/, and runs them."""
     testfiles = [ ]
     for test in glob(pjoin(self._dir, 'tests', 'test_*.py')):
         if not test.endswith('__init__.py'):
             testfiles.append('.'.join(
                 ['tests', splitext(basename(test))[0], 'test_suite'])
             )
     testfiles.sort()
     testfiles.reverse()
     tests = TestLoader().loadTestsFromNames(testfiles)
     runner = TextTestRunner(verbosity = 1)
     runner.run(tests)
예제 #54
0
    def run_unittest(self):
        """Finds all the tests modules in zmq/tests/ and runs them."""
        from unittest import TextTestRunner, TestLoader

        testfiles = []
        for t in glob(pjoin(self._dir, 'tests', '*.py')):
            name = splitext(basename(t))[0]
            if name.startswith('test_'):
                testfiles.append('.'.join(
                    ['tests', name])
                )
        tests = TestLoader().loadTestsFromNames(testfiles)
        t = TextTestRunner(verbosity=2)
        t.run(tests)
예제 #55
0
    def run(self):
        '''
        Finds all the tests modules in tests/, and runs them.
        '''
        testfiles = []
        for t in glob(pjoin(self._dir, 'tests', 'unit', '*.py')):
            if not t.endswith('__init__.py'):
                testfiles.append('.'.join(
                    ['tests', 'unit', splitext(basename(t))[0]])
                )

        print('Running tests: %s' % testfiles)
        tests = TestLoader().loadTestsFromNames(testfiles)
        t = TextTestRunner(verbosity = 1)
        t.run(tests)
예제 #56
0
    def run(self):
        import lzw
        success = doctest.testmod(lzw).failed == 0

        utests = defaultTestLoader.loadTestsFromName(TEST_MODULE_NAME)
        urunner = TextTestRunner(verbosity=2)
        success &= urunner.run(utests).wasSuccessful()

        if self.runslow:
            utests = defaultTestLoader.loadTestsFromName(SLOW_TEST_MODULE_NAME)
            urunner = TextTestRunner(verbosity=2)
            success &= urunner.run(utests).wasSuccessful()

        if not success:
            raise distutils.errors.DistutilsError('Test failure')
예제 #57
0
def test_all():
    loader = TestLoader()
    suites = [
        loader.loadTestsFromTestCase(TestRole),
        loader.loadTestsFromTestCase(TestIP),
        loader.loadTestsFromTestCase(TestHost),
        loader.loadTestsFromTestCase(TestRoleMap),
        loader.loadTestsFromTestCase(TestApi),
        loader.loadTestsFromTestCase(TestHostsOutput),
        loader.loadTestsFromTestCase(TestValidator),
    ]

    testsuites = TestSuite(suites)
    runner = TextTestRunner()
    runner.run(testsuites)
예제 #58
0
def main():
    cov = Coverage(
        omit=[
            "*passlib*",
            "*test*",
            "*tornado*",
            "*backports_abc*",
            "*singledispatch*",
            "*six*",
            "*certifi*",
            "*daemon*",
            "*funcsigs*",
            "*mock*",
            "*pbr*",
            "*pkg_resources*",
            "*tablib*",
        ]
    )

    cov.start()

    from app_test import ApplicationTest
    from database_test import DatabaseTest
    from http_test import HTTPTestCase
    from procinfo_test import ProcInfoTest
    from user_test import UserTest
    from token_test import TokenTest
    from ws_test import WebSocketTestCase
    from unittest import TestLoader, TextTestRunner, TestSuite

    loader = TestLoader()
    suite = TestSuite(
        (
            loader.loadTestsFromTestCase(ProcInfoTest),
            loader.loadTestsFromTestCase(DatabaseTest),
            loader.loadTestsFromTestCase(UserTest),
            loader.loadTestsFromTestCase(TokenTest),
            loader.loadTestsFromTestCase(HTTPTestCase),
            loader.loadTestsFromTestCase(WebSocketTestCase),
            loader.loadTestsFromTestCase(ApplicationTest),
        )
    )

    runner = TextTestRunner(verbosity=2)
    runner.run(suite)

    cov.stop()
    cov.save()