MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / check_models_are_tested

Function check_models_are_tested

diffusers/utils/check_repo.py:372–394  ·  view source on GitHub ↗

Check models defined in module are tested in test_file.

(module, test_file)

Source from the content-addressed store, hash-verified

370
371
372def check_models_are_tested(module, test_file):
373 """Check models defined in module are tested in test_file."""
374 # XxxModelMixin are not tested
375 defined_models = get_models(module)
376 tested_models = find_tested_models(test_file)
377 if tested_models is None:
378 if test_file.replace(os.path.sep, "/") in TEST_FILES_WITH_NO_COMMON_TESTS:
379 return
380 return [
381 f"{test_file} should define `all_model_classes` to apply common tests to the models it tests. "
382 + "If this intentional, add the test filename to `TEST_FILES_WITH_NO_COMMON_TESTS` in the file "
383 + "`utils/check_repo.py`."
384 ]
385 failures = []
386 for model_name, _ in defined_models:
387 if model_name not in tested_models and model_name not in IGNORE_NON_TESTED:
388 failures.append(
389 f"{model_name} is defined in {module.__name__} but is not tested in "
390 + f"{os.path.join(PATH_TO_TESTS, test_file)}. Add it to the all_model_classes in that file."
391 + "If common tests should not applied to that model, add its name to `IGNORE_NON_TESTED`"
392 + "in the file `utils/check_repo.py`."
393 )
394 return failures
395
396
397def check_all_models_are_tested():

Callers 1

Calls 2

get_modelsFunction · 0.85
find_tested_modelsFunction · 0.85

Tested by

no test coverage detected