Example #1
0
        # it's not a list, it's not a bare module - let's see if it's an honest-to-god TestCaseBase
        elif isinstance(test_module, MetaTestCase) and (not '__test__' in test_module.__dict__ or bool(test_module.__test__)):
                if test_module not in discover_set:
                    _log.debug("discover: discovered %s" % test_module)
                    if suites:
                        if not hasattr(test_module, '_suites'):
                            setattr(test_module, '_suites', set())
                        elif not isinstance(test_module._suites, set):
                            test_module._suites = set(test_module._suites)
                        test_module._suites = test_module._suites | set(suites)
                    discover_set.add(test_module)
                    yield test_module

        # detect unittest test cases
        elif issubclass(test_module, unittest.TestCase) and (not '__test__' in test_module.__dict__ or bool(test_module.__test__)):
            test_case = TestifiedUnitTest.from_unittest_case(test_module, module_suites=suites)
            discover_set.add(test_case)
            yield test_case

    discover_set = set()
    time_start = time.time()

    for discovery in discover_inner(what):
        yield discovery

    time_end = time.time()
    _log.debug("discover: discovered %d test cases in %s" % (len(discover_set), time_end - time_start))

def import_test_class(module_path, class_name):
    for klass in discover(module_path):
        if klass.__name__ == class_name:
Example #2
0
                    obj = getattr(test_module, member_name)
                    if isinstance(obj, types.TypeType) and inspect.getmodule(obj) == test_module:
                        for test_case_class in discover_inner(obj, suites + module_suites):
                            yield test_case_class

        # it's not a list, it's not a bare module - let's see if it's an honest-to-god TestCaseBase
        elif isinstance(test_module, MetaTestCase) and (not '__test__' in test_module.__dict__ or bool(test_module.__test__)):
                if test_module not in discover_set:
                    _log.debug("discover: discovered %s" % test_module)
                    if suites:
                        if not hasattr(test_module, '_suites'):
                            setattr(test_module, '_suites', set())
                        elif not isinstance(test_module._suites, set):
                            test_module._suites = set(test_module._suites)
                        test_module._suites = test_module._suites | set(suites)
                    discover_set.add(test_module)
                    yield test_module

        # detect unittest test cases
        elif issubclass(test_module, unittest.TestCase) and (not '__test__' in test_module.__dict__ or bool(test_module.__test__)):
            test_case = TestifiedUnitTest.from_unittest_case(test_module)
            discover_set.add(test_case)
            yield test_case

    discover_set = set()
    time_start = time.time()
    for discovery in discover_inner(what):
        yield discovery
    time_end = time.time()
    _log.debug("discover: discovered %d test cases in %s" % (len(discover_set), time_end - time_start))
Example #3
0
                test_module,
                MetaTestCase) and (not '__test__' in test_module.__dict__
                                   or bool(test_module.__test__)):
            if test_module not in discover_set:
                _log.debug("discover: discovered %s" % test_module)
                if suites:
                    if not hasattr(test_module, '_suites'):
                        setattr(test_module, '_suites', set())
                    elif not isinstance(test_module._suites, set):
                        test_module._suites = set(test_module._suites)
                    test_module._suites = test_module._suites | set(suites)
                discover_set.add(test_module)
                yield test_module

        # detect unittest test cases
        elif issubclass(
                test_module,
                unittest.TestCase) and (not '__test__' in test_module.__dict__
                                        or bool(test_module.__test__)):
            test_case = TestifiedUnitTest.from_unittest_case(test_module)
            discover_set.add(test_case)
            yield test_case

    discover_set = set()
    time_start = time.time()
    for discovery in discover_inner(what):
        yield discovery
    time_end = time.time()
    _log.debug("discover: discovered %d test cases in %s" %
               (len(discover_set), time_end - time_start))