Get the model test files. The returned files should NOT contain the `tests` (i.e. `PATH_TO_TESTS` defined in this script). They will be considered as paths relative to `tests`. A caller has to use `os.path.join(PATH_TO_TESTS, ...)` to access the files.
()
| 313 | # If some test_modeling files should be ignored when checking models are all tested, they should be added in the |
| 314 | # nested list _ignore_files of this function. |
| 315 | def get_model_test_files(): |
| 316 | """Get the model test files. |
| 317 | |
| 318 | The returned files should NOT contain the `tests` (i.e. `PATH_TO_TESTS` defined in this script). They will be |
| 319 | considered as paths relative to `tests`. A caller has to use `os.path.join(PATH_TO_TESTS, ...)` to access the files. |
| 320 | """ |
| 321 | |
| 322 | _ignore_files = [ |
| 323 | "test_modeling_common", |
| 324 | "test_modeling_encoder_decoder", |
| 325 | "test_modeling_flax_encoder_decoder", |
| 326 | "test_modeling_flax_speech_encoder_decoder", |
| 327 | "test_modeling_marian", |
| 328 | "test_modeling_tf_common", |
| 329 | "test_modeling_tf_encoder_decoder", |
| 330 | ] |
| 331 | test_files = [] |
| 332 | # Check both `PATH_TO_TESTS` and `PATH_TO_TESTS/models` |
| 333 | model_test_root = os.path.join(PATH_TO_TESTS, "models") |
| 334 | model_test_dirs = [] |
| 335 | for x in os.listdir(model_test_root): |
| 336 | x = os.path.join(model_test_root, x) |
| 337 | if os.path.isdir(x): |
| 338 | model_test_dirs.append(x) |
| 339 | |
| 340 | for target_dir in [PATH_TO_TESTS] + model_test_dirs: |
| 341 | for file_or_dir in os.listdir(target_dir): |
| 342 | path = os.path.join(target_dir, file_or_dir) |
| 343 | if os.path.isfile(path): |
| 344 | filename = os.path.split(path)[-1] |
| 345 | if "test_modeling" in filename and os.path.splitext(filename)[0] not in _ignore_files: |
| 346 | file = os.path.join(*path.split(os.sep)[1:]) |
| 347 | test_files.append(file) |
| 348 | |
| 349 | return test_files |
| 350 | |
| 351 | |
| 352 | # This is a bit hacky but I didn't find a way to import the test_file as a module and read inside the tester class |
no outgoing calls
no test coverage detected