예제 #1
0
def execute_tests_matching(logger, test_source, module_glob):
    test_module_names = discover_modules_matching(test_source, module_glob)
    test_modules = import_modules(test_module_names)

    test_collector = TestCollector()

    for test_module in test_modules:
        test_collector.collect_tests(test_module)

    test_runner = TestRunner()
    test_runner.add_test_run_listener(TestListener(logger))
    return test_runner.run_tests(test_collector.test_suite)
예제 #2
0
def execute_tests(logger, test_source, suffix):
    test_module_names = discover_modules(test_source, suffix)
    test_modules = import_modules(test_module_names)

    test_collector = TestCollector()

    for test_module in test_modules:
        test_collector.collect_tests(test_module)

    test_runner = TestRunner()
    test_runner.add_test_run_listener(TestListener(logger))
    return test_runner.run_tests(test_collector.test_suite)
예제 #3
0
class TestCollectorTest(unittest.TestCase):
    def setUp (self):
        self.collector = TestCollector()

    def test_should_collect_single_test_from_module (self):
        @test
        def some_test ():
            pass

        module_mock = mock()
        module_mock.some_test = some_test

        self.collector.collect_tests(module_mock)

        assert_that(len(self.collector.test_suite)).equals(1)

    def test_should_not_collect_method_not_marked_as_test (self):
        def some_test ():
            pass

        module_mock = mock()
        module_mock.some_test = some_test

        self.collector.collect_tests(module_mock)

        assert_that(len(self.collector.test_suite)).equals(0)

    def test_should_collect_two_tests_from_module (self):
        @test
        def some_test ():
            pass

        @test
        def some_other_test ():
            pass

        module_mock = mock()
        module_mock.some_test = some_test
        module_mock.some_other_test = some_other_test

        self.collector.collect_tests(module_mock)

        assert_that(len(self.collector.test_suite)).equals(2)