MCPcopy Index your code
hub / github.com/python/cpython / findtests

Function findtests

Lib/test/libregrtest/findtests.py:40–63  ·  view source on GitHub ↗

Return a list of all applicable test modules.

(*, testdir: StrPath | None = None, exclude: Container[str] = (),
              split_test_dirs: set[TestName] = SPLITTESTDIRS,
              base_mod: str = "")

Source from the content-addressed store, hash-verified

38
39
40def findtests(*, testdir: StrPath | None = None, exclude: Container[str] = (),
41 split_test_dirs: set[TestName] = SPLITTESTDIRS,
42 base_mod: str = "") -> TestList:
43 """Return a list of all applicable test modules."""
44 testdir = findtestdir(testdir)
45 tests = []
46 for name in os.listdir(testdir):
47 mod, ext = os.path.splitext(name)
48 if (not mod.startswith("test_")) or (mod in exclude):
49 continue
50 if base_mod:
51 fullname = f"{base_mod}.{mod}"
52 else:
53 fullname = mod
54 if fullname in split_test_dirs:
55 subdir = os.path.join(testdir, mod)
56 if not base_mod:
57 fullname = f"test.{mod}"
58 tests.extend(findtests(testdir=subdir, exclude=exclude,
59 split_test_dirs=split_test_dirs,
60 base_mod=fullname))
61 elif ext in (".py", ""):
62 tests.append(fullname)
63 return sorted(tests)
64
65
66def split_test_packages(tests, *, testdir: StrPath | None = None,

Callers 2

find_testsMethod · 0.90
split_test_packagesFunction · 0.85

Calls 7

findtestdirFunction · 0.85
listdirMethod · 0.80
splitextMethod · 0.80
startswithMethod · 0.45
joinMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…