Parse the content of test_file to detect what's in all_model_classes
(test_file)
| 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 |
| 353 | # for the all_model_classes variable. |
| 354 | def find_tested_models(test_file): |
| 355 | """Parse the content of test_file to detect what's in all_model_classes""" |
| 356 | # This is a bit hacky but I didn't find a way to import the test_file as a module and read inside the class |
| 357 | with open(os.path.join(PATH_TO_TESTS, test_file), "r", encoding="utf-8", newline="\n") as f: |
| 358 | content = f.read() |
| 359 | all_models = re.findall(r"all_model_classes\s+=\s+\(\s*\(([^\)]*)\)", content) |
| 360 | # Check with one less parenthesis as well |
| 361 | all_models += re.findall(r"all_model_classes\s+=\s+\(([^\)]*)\)", content) |
| 362 | if len(all_models) > 0: |
| 363 | model_tested = [] |
| 364 | for entry in all_models: |
| 365 | for line in entry.split(","): |
| 366 | name = line.strip() |
| 367 | if len(name) > 0: |
| 368 | model_tested.append(name) |
| 369 | return model_tested |
| 370 | |
| 371 | |
| 372 | def check_models_are_tested(module, test_file): |
no outgoing calls
no test coverage detected