Merge pull request #24474 from blaggacao/fix/run-tests-module-def

fix: run-tests --module-def as not all doctypes are guaranteed to have test_*.py files
This commit is contained in:
Ankush Menat 2024-01-31 18:52:45 +05:30 committed by GitHub
commit 5e904d407e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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
)