def build_suite(app): discovery_root = get_app_location(app) top_level_dir = discovery_root for _ in range(0, app.__name__.count('.')): top_level_dir = os.path.dirname(top_level_dir) return defaultTestLoader.discover(discovery_root, top_level_dir=top_level_dir)
def build_suite(app): discovery_root = get_app_location(app) if os.path.isdir(os.path.join(discovery_root, 'tests')): discovery_root = os.path.join(discovery_root, 'tests') top_level_dir = discovery_root else: top_level_dir = discovery_root for _ in range(0, app.__name__.count('.')): top_level_dir = os.path.dirname(top_level_dir) return defaultTestLoader.discover(discovery_root, top_level_dir=top_level_dir)
def build_suite(self, test_labels, extra_tests=None, **kwargs): suite = None root = getattr(settings, 'TEST_DISCOVER_ROOT', '.') top_level = getattr(settings, 'TEST_DISCOVER_TOP_LEVEL', None) pattern = getattr(settings, 'TEST_DISCOVER_PATTERN', 'test*.py') if test_labels: suite = defaultTestLoader.loadTestsFromNames(test_labels) # if single named module has no tests, do discovery within it if not suite.countTestCases() and len(test_labels) == 1: suite = None root = import_module(test_labels[0]).__path__[0] if suite is None: suite = defaultTestLoader.discover(root, pattern=pattern, top_level_dir=top_level) if extra_tests: for test in extra_tests: suite.addTest(test) return reorder_suite(suite, (TestCase,))