MCPcopy
hub / github.com/django/django / get_test_modules

Function get_test_modules

tests/runtests.py:108–137  ·  view source on GitHub ↗

Scan the tests directory and yield the names of all test modules. The yielded names have either one dotted part like "test_runner" or, in the case of GIS tests, two dotted parts like "gis_tests.gdal_tests".

(gis_enabled)

Source from the content-addressed store, hash-verified

106
107
108def get_test_modules(gis_enabled):
109 """
110 Scan the tests directory and yield the names of all test modules.
111
112 The yielded names have either one dotted part like "test_runner" or, in
113 the case of GIS tests, two dotted parts like "gis_tests.gdal_tests".
114 """
115 discovery_dirs = [""]
116 if gis_enabled:
117 # GIS tests are in nested apps
118 discovery_dirs.append("gis_tests")
119 else:
120 SUBDIRS_TO_SKIP[""].add("gis_tests")
121
122 for dirname in discovery_dirs:
123 dirpath = os.path.join(RUNTESTS_DIR, dirname)
124 subdirs_to_skip = SUBDIRS_TO_SKIP[dirname]
125 with os.scandir(dirpath) as entries:
126 for f in entries:
127 if (
128 "." in f.name
129 or os.path.basename(f.name) in subdirs_to_skip
130 or f.is_file()
131 or not os.path.exists(os.path.join(f.path, "__init__.py"))
132 ):
133 continue
134 test_module = f.name
135 if dirname:
136 test_module = dirname + "." + test_module
137 yield test_module
138
139
140def get_label_module(label):

Callers 2

mainFunction · 0.90

Calls 4

appendMethod · 0.45
addMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected