Example #1
0
def suite():
    from unittest import TestSuite, defaultTestLoader

    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestRDFHelp))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestRDFSchemas))
    return suite
Example #2
0
def suite():
    suite = TestSuite()
    suite.addTests(
        defaultTestLoader.loadTestsFromTestCase(TestSubmissionModule))
    suite.addTests(
        defaultTestLoader.loadTestsFromTestCase(TestSubmission))
    return suite
Example #3
0
def suite():
    suite = TestSuite()
    suite.addTest(
        defaultTestLoader.loadTestsFromTestCase(TestWildcardMatching))
    suite.addTest(
        defaultTestLoader.loadTestsFromTestCase(TestFindCommonPrefix))
    return suite
Example #4
0
def suite():
    suite = TestSuite()
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestParseLine))
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestFuzzyMatch))
    suite.addTest(
        defaultTestLoader.loadTestsFromTestCase(TestAppIdentification))
    return suite
Example #5
0
def suite_validate_content():
    suite = defaultTestLoader.loadTestsFromTestCase(
        tests.test_validate_content.TestValidateTools)
    suite.addTest(
        defaultTestLoader.loadTestsFromTestCase(
            tests.test_validate_content.TestValidateScripts))
    return suite
Example #6
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(LibraryAccessionTestCase))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(LibraryTestCase))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(SampleWebTestCase))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestRDFaLibrary))
    return suite
Example #7
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(MatchCodeTests))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestMappedReads))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(ElandTests))
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestElandMatches))
    return suite
Example #8
0
 def tests(self):
     from unittest import defaultTestLoader
     yield defaultTestLoader.loadTestsFromTestCase(DetectorTest)
     yield defaultTestLoader.loadTestsFromTestCase(ImporterTest)
     from hwp5_uno.tests import test_hwp5_uno
     yield defaultTestLoader.loadTestsFromModule(test_hwp5_uno)
     from hwp5.tests import test_suite
     yield test_suite()
Example #9
0
 def tests(self):
     from unittest import defaultTestLoader
     yield defaultTestLoader.loadTestsFromTestCase(DetectorTest)
     yield defaultTestLoader.loadTestsFromTestCase(ImporterTest)
     from hwp5_uno.tests import test_hwp5_uno
     yield defaultTestLoader.loadTestsFromModule(test_hwp5_uno)
     from hwp5.tests import test_suite
     yield test_suite()
Example #10
0
def runUnitTest():
    moc_stdout = StringIO()
    runner = unittest.TextTestRunner(moc_stdout)
    suite = loader.loadTestsFromTestCase(TestMacroCommand)
    runner.run(suite)
    suite = loader.loadTestsFromTestCase(ParserTest)
    runner.run(suite)
    lx.out(moc_stdout.getvalue())
Example #11
0
def full_suite():
    # Metadata classes
    suite = defaultTestLoader.loadTestsFromTestCase(TestMakeToolMetadata)
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestMakeSubtoolMetadata))
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestMakeParentToolMetadata))

    # Get metadata
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestMetadataFromBioTools))
    return suite
Example #12
0
def selftest(logger):
    if os.environ.get('BORG_SELFTEST') == 'disabled':
        logger.debug("borg selftest disabled via BORG_SELFTEST env variable")
        return
    selftest_started = time.perf_counter()
    result = SelfTestResult()
    test_suite = TestSuite()
    for test_case in SELFTEST_CASES:
        module = sys.modules[test_case.__module__]
        # a normal borg user does not have pytest installed, we must not require it in the test modules used here.
        # note: this only detects the usual toplevel import
        assert 'pytest' not in dir(module), "pytest must not be imported in %s" % module.__name__
        test_suite.addTest(defaultTestLoader.loadTestsFromTestCase(test_case))
    test_suite.run(result)
    result.log_results(logger)
    successful_tests = result.successful_test_count()
    count_mismatch = successful_tests != SELFTEST_COUNT
    if result.wasSuccessful() and count_mismatch:
        # only print this if all tests succeeded
        logger.error("self test count (%d != %d) mismatch, either test discovery is broken or a test was added "
                     "without updating borg.selftest",
                     successful_tests, SELFTEST_COUNT)
    if not result.wasSuccessful() or count_mismatch:
        logger.error("self test failed\n"
                     "Could be a bug either in Borg, the package / distribution you use, your OS or your hardware.")
        sys.exit(2)
        assert False, "sanity assertion failed: ran beyond sys.exit()"
    selftest_elapsed = time.perf_counter() - selftest_started
    logger.debug("%d self tests completed in %.2f seconds", successful_tests, selftest_elapsed)
Example #13
0
def selftest(logger):
    selftest_started = time.perf_counter()
    result = SelfTestResult()
    test_suite = TestSuite()
    for test_case in SELFTEST_CASES:
        test_suite.addTest(defaultTestLoader.loadTestsFromTestCase(test_case))
    test_suite.run(result)
    result.log_results(logger)
    successful_tests = result.successful_test_count()
    count_mismatch = successful_tests != SELFTEST_COUNT
    if result.wasSuccessful() and count_mismatch:
        # only print this if all tests succeeded
        logger.error(
            "self test count (%d != %d) mismatch, either test discovery is broken or a test was added "
            "without updating borg.selftest", successful_tests, SELFTEST_COUNT)
    if not result.wasSuccessful() or count_mismatch:
        logger.error(
            "self test failed\n"
            "This is a bug either in Borg or in the package / distribution you use."
        )
        sys.exit(2)
        assert False, "sanity assertion failed: ran beyond sys.exit()"
    selftest_elapsed = time.perf_counter() - selftest_started
    logger.debug("%d self tests completed in %.2f seconds", successful_tests,
                 selftest_elapsed)
Example #14
0
    def _execute_test(cls, test: FirmwareTestClass, router: Router, routers: List[Router]) -> TestResult:
        if not isinstance(router, Router):
            raise ValueError("Chosen Router is not a real Router...")
        # proofed: this method runs in other process as the server
        setproctitle(str(router.id) + " - " + str(test))
        logging.debug("%sExecute test " + str(test) + " on Router(" + str(router.id) + ")", LoggerSetup.get_log_deep(2))

        test_suite = defaultTestLoader.loadTestsFromTestCase(test)

        # prepare all test cases
        for test_case in test_suite:
            logging.debug("%sTestCase " + str(test_case), LoggerSetup.get_log_deep(4))
            test_case.prepare(router, routers)

        result = TestResult()

        cls.__setns(router)
        try:

            result = test_suite.run(result)
        except Exception as e:
            logging.error("%sTestCase execution raised an exception", LoggerSetup.get_log_deep(3))
            logging.error("%s" + str(e), LoggerSetup.get_log_deep(3))

            test_obj = test()
            result.addError(test_obj, sys.exc_info())  # add the reason of the exception
        finally:

            # I'm sry for this dirty hack, but if you don't do this you get an
            # "TypeError: cannot serialize '_io.TextIOWrapper' object" because sys.stdout is not serializeable...
            result._original_stdout = None
            result._original_stderr = None

            logging.debug("%sResult from test " + str(result), LoggerSetup.get_log_deep(3))
            return result
    def add_test(self, test):
        class CurrentResultRecyclerTest(ResultRecyclerTest):
            pass

        CurrentResultRecyclerTest.init(**test)
        self.addTest(
            defaultTestLoader.loadTestsFromTestCase(CurrentResultRecyclerTest))
Example #16
0
 def run(self):
     test_suite = TestSuite(tests=[
         defaultTestLoader.loadTestsFromTestCase(TestHamming),
         defaultTestLoader.loadTestsFromTestCase(TestSortTrainLabelsKNN),
         defaultTestLoader.loadTestsFromTestCase(TestPYXKNN),
         defaultTestLoader.loadTestsFromTestCase(TestClassificationError),
         defaultTestLoader.loadTestsFromTestCase(TestModelSelectionKNN),
         defaultTestLoader.loadTestsFromTestCase(TestEstimateAPrioriNB),
         defaultTestLoader.loadTestsFromTestCase(TestEstimatePXYNB),
         defaultTestLoader.loadTestsFromTestCase(TestPYXNB),
         defaultTestLoader.loadTestsFromTestCase(TestModelSelectionNB),
     ])
     return self.runner.run(test_suite)
Example #17
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    for testcase in [ExerimentsTestCases,
                     TestEmailNotify,
                     TestSequencer]:
        suite.addTests(defaultTestLoader.loadTestsFromTestCase(testcase))
    return suite
    def add_test(self, test):
        class CurrentVectorConverterTest(VectorConverterTest):
            pass

        CurrentVectorConverterTest.init(**test)
        self.addTest(
            defaultTestLoader.loadTestsFromTestCase(
                CurrentVectorConverterTest))
Example #19
0
def full_suite():

    suite = unittest.TestSuite()

    testcases = [RequestHandlerTestCase, MsgPackTestCase]

    for testcase in testcases:
        suite.addTests(defaultTestLoader.loadTestsFromTestCase(testcase))

    return suite
Example #20
0
 def run(self):
     test_suite = TestSuite(tests=[
         defaultTestLoader.loadTestsFromTestCase(TestSigmoid),
         defaultTestLoader.loadTestsFromTestCase(TestLogisticCostFunction),
         defaultTestLoader.loadTestsFromTestCase(TestGradientDescent),
         defaultTestLoader.loadTestsFromTestCase(TestStochasticGradientDescent),
         defaultTestLoader.loadTestsFromTestCase(TestRegularizedLogisticCostFunction),
         defaultTestLoader.loadTestsFromTestCase(TestPrediction),
         defaultTestLoader.loadTestsFromTestCase(TestFMeasure),
         defaultTestLoader.loadTestsFromTestCase(TestModelSelection),
     ])
     return self.runner.run(test_suite)
Example #21
0
def suite():
    return defaultTestLoader.loadTestsFromTestCase((
        TestMediator,
        TestDB,
        TestParser,
        TestCrawler,
        TestCommandHandler,
        # TestCrawlerWeb,
        TestClientCache,
        TestCommandParser))
Example #22
0
    def add_test(self, test):
        class TestUnweightedMetric(TestMetricSkeleton):
            @classmethod
            def init(cls, metric_class, distance):
                super().init(metric_class, distance)
                cls.name += " unweighted"

            def setUp(self):
                self.metric = self.metric_class()
                super().setUp()

        class TestWeightedMetric(TestMetricSkeleton):
            @classmethod
            def init(cls, metric_class, distance):
                super().init(metric_class, distance)
                cls.name += " weighted"

            def setUp(self):
                self.metric = self.metric_class(self.weights)
                super().setUp()

        class TestBoundedMetric(TestMetricSkeleton):
            @classmethod
            def init(cls, metric_class, distance):
                super().init(metric_class, distance)
                cls.name += " bounded"

            def setUp(self):
                self.metric = self.metric_class(self.bounds)
                super().setUp()

        TestUnweightedMetric.init(test['metric_class'],
                                  test['unweighted_distance'])
        self.addTest(
            defaultTestLoader.loadTestsFromTestCase(TestUnweightedMetric))
        TestWeightedMetric.init(test['metric_class'],
                                test['weighted_distance'])
        self.addTest(
            defaultTestLoader.loadTestsFromTestCase(TestWeightedMetric))
        TestBoundedMetric.init(test['metric_class'], test['weighted_distance'])
        self.addTest(
            defaultTestLoader.loadTestsFromTestCase(TestBoundedMetric))
Example #23
0
    def test_with_stdout(self):
        class LoudTestCase(TestCase):
            def test(self):
                print('True is true, who knew!')
                self.assertTrue(True)

        loud_suite = TestSuite(
            tests=defaultTestLoader.loadTestsFromTestCase(LoudTestCase))

        with self.assertRaises(RuntimeError):
            self._run_suite(loud_suite)
Example #24
0
    def test_with_no_stdout(self):
        class QuietTestCase(TestCase):
            def test(self):
                self.assertTrue(True)

        quiet_suite = TestSuite(
            tests=defaultTestLoader.loadTestsFromTestCase(QuietTestCase))
        result = self._run_suite(quiet_suite)

        # No errors should be raised and the suite should have passed
        self.assertEqual(result.errors, [])
        self.assertEqual(result.failures, [])
Example #25
0
    def test_with_stdout(self):
        class LoudTestCase(TestCase):
            def test(self):
                print('True is true, who knew!')
                self.assertTrue(True)

        loud_suite = TestSuite(
            tests=defaultTestLoader.loadTestsFromTestCase(LoudTestCase)
        )

        with self.assertRaises(RuntimeError):
            self._run_suite(loud_suite)
Example #26
0
    def test_with_no_stdout(self):
        class QuietTestCase(TestCase):
            def test(self):
                self.assertTrue(True)

        quiet_suite = TestSuite(
            tests=defaultTestLoader.loadTestsFromTestCase(QuietTestCase)
        )
        result = self._run_suite(quiet_suite)

        # No errors should be raised and the suite should have passed
        self.assertEqual(result.errors, [])
        self.assertEqual(result.failures, [])
    def __init__(self, single_test=None):
        super().__init__()

        if single_test is None:
            self.addTest(
                defaultTestLoader.loadTestsFromTestCase(
                    VectorConverterFailTest))

        converter_tests = [single_test] if single_test is not None else [
            {
                'converter_class': rr_vector.ScalarConverter,
                'sample_data': 2.5,
                'conv_data': array([2.5]),
                'dim': 1,
                'keys': (0, )
            },
            {
                'converter_class': rr_vector.NdArrayConverter,
                'sample_data': array([2, 3.5]),
                'conv_data': array([2, 3.5]),
                'dim': 2,
                'keys': (0, 1)
            },
            {
                'converter_class': rr_vector.ListConverter,
                'sample_data': [2, 3.5],
                'conv_data': array([2, 3.5]),
                'dim': 2,
                'keys': (0, 1)
            },
            {
                'converter_class': rr_vector.TupleConverter,
                'sample_data': (2, 3.5),
                'conv_data': array([2, 3.5]),
                'dim': 2,
                'keys': (0, 1)
            },
            {
                'converter_class': rr_vector.DictConverter,
                'sample_data': {
                    'a': 2,
                    'b': 3.5
                },
                'conv_data': array([2, 3.5]),
                'dim': 2,
                'keys': ('a', 'b')
            },
        ]

        for test in converter_tests:
            self.add_test(test)
def main(path="."):
    wasSuccessful = True
    suites = TestSuite()
    #path = os.path.abspath(path)
    print "path='%s'" % path
    if type(path) is type([]):
        paths = [os.path.abspath(p) for p in path]
        [sys.path.append(p) for p in paths]
    else:
        if os.path.split(path)[1] == "apps":
            paths = []
            sys.path.append(path)
            for file in os.listdir(path):
                p = os.path.join(path, file)
                if os.path.isdir(p) and not file.startswith("."):
                    paths.append(p)
                    sys.path.append(p)
            print
            print "**********************"
            print "%s" % paths
            print "**********************"
            print
        else:
            sys.path.append(path)
            paths = [path]

    for path in paths:
        os.chdir(path)
        print
        print "**********************"
        print "Processing '%s'" % path
        print "**********************"
        print
        testClasses = getAllTestClasses(path=path)
        for filename, testClassName, testClass in testClasses:
            suite = defaultTestLoader.loadTestsFromTestCase(testClass)
            print "file='%s', class='%s', test=%s" % (filename, testClassName,
                                                      suite.countTestCases())
            #result = TextTestRunner(verbosity=1).run(suite)
            #if not result.wasSuccessful:
            #    wasSuccessful = False
            suites.addTest(suite)
        result = TextTestRunner(verbosity=1).run(suites)
        if result.wasSuccessful == False:
            wasSuccessful = False
    if wasSuccessful:
        print "Completed all tests OK."
        return True
    else:
        print "*** One or more tests Failed! ***"
        return result
def main(path="."):
    wasSuccessful = True
    suites = TestSuite()
    #path = os.path.abspath(path)
    print "path='%s'" % path
    if type(path) is type([]):
        paths = [os.path.abspath(p) for p in path]
        [sys.path.append(p) for p in paths]
    else:
        if os.path.split(path)[1]=="apps":
            paths = []
            sys.path.append(path)
            for file in os.listdir(path):
                p = os.path.join(path, file)
                if os.path.isdir(p) and not file.startswith("."):
                    paths.append(p)
                    sys.path.append(p)
            print
            print "**********************"
            print "%s" % paths
            print "**********************"
            print 
        else:
            sys.path.append(path)
            paths = [path]
    
    for path in paths:
        os.chdir(path)
        print
        print "**********************"
        print "Processing '%s'" % path
        print "**********************"
        print
        testClasses = getAllTestClasses(path=path)
        for filename, testClassName, testClass in testClasses:
            suite = defaultTestLoader.loadTestsFromTestCase(testClass)
            print "file='%s', class='%s', test=%s" % (filename, testClassName, suite.countTestCases())
            #result = TextTestRunner(verbosity=1).run(suite)
            #if not result.wasSuccessful:
            #    wasSuccessful = False
            suites.addTest(suite)
        result = TextTestRunner(verbosity=1).run(suites)
        if result.wasSuccessful==False:
            wasSuccessful = False
    if wasSuccessful:
        print "Completed all tests OK."
        return True
    else:
        print "*** One or more tests Failed! ***"
        return result
def RunTests():
    global TestLoader, TextTestRunner

    tests = [
        TestSpeech2Text,
        TestTemplateGen,
    ]

    for testItem in tests:
        testItem.MemoryCtx = MemoryCtx
        suite = defaultTestLoader.loadTestsFromTestCase(testItem)
        res = TextTestRunner(verbosity=2).run(suite)
        if not res.wasSuccessful():
            raise Exception("Unit test failed")
Example #31
0
    def test_with_stdout(self):
        class LoudTestCase(TestCase):
            def test(self):
                print('True is true, who knew!')
                self.assertTrue(True)

        loud_suite = TestSuite(
            tests=defaultTestLoader.loadTestsFromTestCase(LoudTestCase)
        )

        with self.assertRaises(AssertionError):
            StdoutCapturingTestRunner(verbosity=0).run_suite(
                loud_suite,
                stream=StringIO()
            )
Example #32
0
def RunTests():
    global TestLoader, TextTestRunner

    tests = [
        TestTextDecomposition,
        TestAgentMethods,
    ]

    for testItem in tests:
        testItem.MemoryCtx = MemoryCtx
        testItem.Module = Module
        suite = defaultTestLoader.loadTestsFromTestCase(testItem)
        res = TextTestRunner(verbosity=2).run(suite)
        if not res.wasSuccessful():
            raise Exception("Unit test failed")
Example #33
0
def RunTests():
    global TestLoader, TextTestRunner, MemoryCtx

    tests = [
        TestScAddr,
        TestScType,
        TestScMemoryContext,
        TestScSet,
        TestEvents,
        TestScHelper,
    ]

    for testItem in tests:
        testItem.MemoryCtx = MemoryCtx
        testItem.module = module
        suite = defaultTestLoader.loadTestsFromTestCase(testItem)
        res = TextTestRunner(verbosity=2).run(suite)
        if not res.wasSuccessful():
            raise Exception("Unit test failed")
Example #34
0
    def test_with_no_stdout(self):
        class QuietTestCase(TestCase):
            def test(self):
                self.assertTrue(True)

        quiet_suite = TestSuite(
            tests=defaultTestLoader.loadTestsFromTestCase(QuietTestCase)
        )

        # Supress test case output while this runs so we don't get weird
        # test-case-in-our-test-case messaging
        result = StdoutCapturingTestRunner().run_suite(
            quiet_suite,
            stream=StringIO()
        )

        # No errors should be raised and the suite should have passed
        self.assertEqual(result.errors, [])
        self.assertEqual(result.failures, [])
Example #35
0
def RunTests():
  global TestLoader, TextTestRunner, MemoryCtx
  
  tests = [
    TestScAddr,
    TestScType,
    TestScMemoryContext,
    TestScSet,
    TestEvents,
    TestScHelper,
    ]

  for testItem in tests:
    testItem.MemoryCtx = MemoryCtx
    testItem.module = module
    suite = defaultTestLoader.loadTestsFromTestCase(testItem)
    res = TextTestRunner(verbosity=2).run(suite)
    if not res.wasSuccessful():
      raise Exception("Unit test failed")
def main(path="."):
    wasSuccessful = True
    suites = TestSuite()
    testClasses = getAllTestClasses(path=path)
    for filename, testClassName, testClass in testClasses:
        suite = defaultTestLoader.loadTestsFromTestCase(testClass)
        print "file='%s', class='%s', test=%s" % (filename, testClassName,
                                                  suite.countTestCases())
        #result = TextTestRunner(verbosity=1).run(suite)
        #if not result.wasSuccessful:
        #    wasSuccessful = False
        suites.addTest(suite)
    result = TextTestRunner(verbosity=1).run(suites)
    wasSuccessful = result.wasSuccessful
    if wasSuccessful:
        print "Completed all tests OK."
        return True
    else:
        print "*** One or more tests Failed! ***"
        return result
Example #37
0
def selftest(logger):
    selftest_started = time.perf_counter()
    result = SelfTestResult()
    test_suite = TestSuite()
    for test_case in SELFTEST_CASES:
        test_suite.addTest(defaultTestLoader.loadTestsFromTestCase(test_case))
    test_suite.run(result)
    result.log_results(logger)
    successful_tests = result.successful_test_count()
    count_mismatch = successful_tests != SELFTEST_COUNT
    if result.wasSuccessful() and count_mismatch:
        # only print this if all tests succeeded
        logger.error("self test count (%d != %d) mismatch, either test discovery is broken or a test was added "
                     "without updating borg.selftest",
                     successful_tests, SELFTEST_COUNT)
    if not result.wasSuccessful() or count_mismatch:
        logger.error("self test failed\n"
                     "This is a bug either in Borg or in the package / distribution you use.")
        sys.exit(2)
        assert False, "sanity assertion failed: ran beyond sys.exit()"
    selftest_elapsed = time.perf_counter() - selftest_started
    logger.debug("%d self tests completed in %.2f seconds", successful_tests, selftest_elapsed)
def main(path="."):
    wasSuccessful = True
    suites = TestSuite()
    #path = os.path.abspath(path)
    path = fs.absPath(path)
    print "path='%s'" % path
    if fs.split(path)[1] == "apps":
        paths = []
        #for file in os.listdir(path):
        for file in fs.list(path):
            #p = os.path.join(path, file)
            p = fs.join(path, file)
            #if os.path.isdir(p) and not file.startswith("."):
            if fs.isDirectory(p) and not file.startswith("."):
                paths.append(p)
    else:
        paths = [path]
    for path in paths:
        #No chdir method id FileSystem
        os.chdir(path)
        print "Processing '%s'" % path
        testClasses = getAllTestClasses(path=path)
        for filename, testClassName, testClass in testClasses:
            suite = defaultTestLoader.loadTestsFromTestCase(testClass)
            print "file='%s', class='%s', test=%s" % (filename, testClassName,
                                                      suite.countTestCases())
            #result = TextTestRunner(verbosity=1).run(suite)
            #if not result.wasSuccessful:
            #    wasSuccessful = False
            suites.addTest(suite)
        result = TextTestRunner(verbosity=1).run(suites)
        if result.wasSuccessful == False:
            wasSuccessful = False
    if wasSuccessful:
        print "Completed all tests OK."
        return True
    else:
        print "*** One or more tests Failed! ***"
        return result
def main(path="."):
    wasSuccessful = True
    suites = TestSuite()
    #path = os.path.abspath(path)
    path = fs.absPath(path)
    print "path='%s'" % path
    if fs.split(path)[1]=="apps":
        paths = []
        #for file in os.listdir(path):
        for file in fs.list(path):
            #p = os.path.join(path, file)
            p = fs.join(path, file)
            #if os.path.isdir(p) and not file.startswith("."):
            if fs.isDirectory(p) and not file.startswith("."):
                paths.append(p)
    else:
        paths = [path]
    for path in paths:
        #No chdir method id FileSystem
        os.chdir(path)
        print "Processing '%s'" % path
        testClasses = getAllTestClasses(path=path)
        for filename, testClassName, testClass in testClasses:
            suite = defaultTestLoader.loadTestsFromTestCase(testClass)
            print "file='%s', class='%s', test=%s" % (filename, testClassName, suite.countTestCases())
            #result = TextTestRunner(verbosity=1).run(suite)
            #if not result.wasSuccessful:
            #    wasSuccessful = False
            suites.addTest(suite)
        result = TextTestRunner(verbosity=1).run(suites)
        if result.wasSuccessful==False:
            wasSuccessful = False
    if wasSuccessful:
        print "Completed all tests OK."
        return True
    else:
        print "*** One or more tests Failed! ***"
        return result
Example #40
0
    def _execute_test(cls, test: FirmwareTestClass,
                      router: Router) -> TestResult:
        if not isinstance(router, Router):
            raise ValueError("Chosen Router is not a real Router...")
        # proofed: this method runs in other process as the server
        logging.debug("%sExecute test " + str(test) + " on " + str(router),
                      LoggerSetup.get_log_deep(2))

        test_suite = defaultTestLoader.loadTestsFromTestCase(test)

        # prepare all test cases
        for test_case in test_suite:
            logging.debug("%sTestCase " + str(test_case),
                          LoggerSetup.get_log_deep(4))
            test_case.prepare(router)

        result = TestResult()

        cls.__setns(router)
        try:

            result = test_suite.run(
                result)  # TODO if debug set, run as debug()
        except Exception as e:
            logging.error("%sTestCase raised an exception",
                          LoggerSetup.get_log_deep(3))
            logging.error("%s" + str(e), LoggerSetup.get_log_deep(3))
        finally:

            # I'm sry for this dirty hack, but if you don't do this you get an
            # "TypeError: cannot serialize '_io.TextIOWrapper' object" because sys.stdout is not serializeable...
            result._original_stdout = None
            result._original_stderr = None

            logging.debug("%sResult from test " + str(result),
                          LoggerSetup.get_log_deep(3))
            return result
Example #41
0
from unittest import defaultTestLoader
from TransactionManager import TransactionManagerBase

test_cases = [TransactionManagerBase]

tests = [defaultTestLoader.loadTestsFromTestCase(test) for test in test_cases]

Example #42
0
def suite():
    suite = TestSuite()
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestWildcardMatching))
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestFindCommonPrefix))
    return suite
Example #43
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(SequenceFileTests))
    return suite
Example #44
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestURLUtilities))
    return suite
Example #45
0
        import requests
        result = requests.get('http://localhost:5000/todo/api/v1.0/tasks/1')
        self.assertEqual(result.status_code, 200)

    def test_get_not_exists_task(self):
        import json
        import requests
        result = requests.get('http://localhost:5000/todo/api/v1.0/tasks/100')
        self.assertEqual(json.loads(result.text), {'error': 'Not found'})


class DDeleteTestCase(TestCase):
    def test_delete_task(self):
        import requests
        result = requests.delete('http://localhost:5000/todo/api/v1.0/tasks/1')
        self.assertEqual(result.status_code, 200)


if __name__ == '__main__':
    suite = list()
    suite.append(defaultTestLoader.loadTestsFromTestCase(AMainTestCase))
    suite.append(defaultTestLoader.loadTestsFromTestCase(BPostPutTestCase))
    suite.append(defaultTestLoader.loadTestsFromTestCase(CGetTestCase))
    suite.append(defaultTestLoader.loadTestsFromTestCase(DDeleteTestCase))

    todoTestSuite = TestSuite()
    todoTestSuite.addTests(suite)

    runner = TextTestRunner(verbosity=2)
    runner.run(todoTestSuite)
Example #46
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(testSrf2Fastq))
    return suite
Example #47
0
def suite():
    return defaultTestLoader.loadTestsFromTestCase(ConverterTester)
Example #48
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestVersion))
    return suite
Example #49
0
def suite():
    suite = TestSuite()
    suite.addTests(
        defaultTestLoader.loadTestsFromTestCase(TestEncoded))
    return suite
Example #50
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(testQueueCommands))
    return suite
Example #51
0
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

import unittest
from unittest import defaultTestLoader as dtl

from utils.storage import *
from utils.html import *
from utils.url import *

from web.chain import *
from web.reverse import *
from web.convs import *
from web.filter import *

from forms.convs import *
from forms.fields import *
from forms.forms import *
from forms.media import *

suite = unittest.TestSuite()

for item in locals().values():
    if isinstance(item, type) and issubclass(item, unittest.TestCase):
        suite.addTest(dtl.loadTestsFromTestCase(item))

if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite)
Example #52
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(testGenomeMapper))
    return suite
Example #53
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(InventoryTestCase))
    return suite
Example #54
0
def suite():
    return defaultTestLoader.loadTestsFromTestCase(HashTableTester)
Example #55
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestRDFMagic))
    return suite
Example #56
0
def run(verbosity=2):
    suite = [
        defaultTestLoader.loadTestsFromTestCase(VimeoTests),
        defaultTestLoader.loadTestsFromTestCase(YouTubeTests),
    ]
    return TextTestRunner(verbosity=verbosity).run(TestSuite(suite))
Example #57
0
def suite():
    suite = TestSuite()
    suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestInputState))
    return suite
Example #58
0
def suite():
    from unittest import TestSuite, defaultTestLoader
    suite = TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromTestCase(RunfolderTests))
    return suite
Example #59
0
def run_testcase(testcase_class):
    """Run all the tests in a TestCase and return them."""
    suite = defaultTestLoader.loadTestsFromTestCase(testcase_class)
    tests = list(suite._tests)
    result = TextTestRunner().run(suite)
    return tests, result