fix: run-tests --module-def as not all doctypes are guaranteed to have test_*.py files

This commit is contained in:
David Arnold 2024-01-21 20:19:26 +01:00
parent 1640aaad04
commit ee50e6c534
No known key found for this signature in database
GPG key ID: AB15A6AF1101390D

View file

@ -89,9 +89,22 @@ def main(
doctype, verbose, tests, force, profile, failfast=failfast, junit_xml_output=junit_xml_output
)
elif module_def:
doctypes = frappe.db.get_list(
"DocType", filters={"module": module_def, "istable": 0}, pluck="name"
doctypes = []
doctypes_ = frappe.get_list(
"DocType",
filters={"module": module_def, "istable": 0},
fields=["name", "module"],
as_list=True,
)
for doctype, module in doctypes_:
test_module = get_module_name(doctype, module, "test_", app=app)
try:
importlib.import_module(test_module)
except Exception:
pass
else:
doctypes.append(doctype)
ret = run_tests_for_doctype(
doctypes, verbose, tests, force, profile, failfast=failfast, junit_xml_output=junit_xml_output
)