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)
| 106 | |
| 107 | |
| 108 | def 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 | |
| 140 | def get_label_module(label): |