fix: Testing Module 28000 (#28032)
* fix: logging text * fix: app handling
This commit is contained in:
parent
a7507c66f2
commit
5324431fc0
3 changed files with 18 additions and 9 deletions
|
|
@ -102,7 +102,7 @@ def main(
|
|||
|
||||
if doctype or doctype_list_path:
|
||||
doctype = _load_doctype_list(doctype_list_path) if doctype_list_path else doctype
|
||||
discover_doctype_tests(doctype, runner, force, app)
|
||||
discover_doctype_tests(doctype, runner, app, force)
|
||||
elif module_def:
|
||||
_run_module_def_tests(app, module_def, runner, force)
|
||||
elif module:
|
||||
|
|
@ -197,7 +197,7 @@ def _run_module_def_tests(app, module_def, runner: "TestRunner", force) -> "Test
|
|||
from frappe.testing import discover_doctype_tests
|
||||
|
||||
doctypes = _get_doctypes_for_module_def(app, module_def)
|
||||
return discover_doctype_tests(doctypes, runner, force, app)
|
||||
return discover_doctype_tests(doctypes, runner, app, force)
|
||||
|
||||
|
||||
def _get_doctypes_for_module_def(app, module_def):
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ def discover_doctype_tests(doctypes: list[str], runner, app: str, force: bool =
|
|||
"""Discover tests for the specified doctype(s)"""
|
||||
if isinstance(doctypes, str):
|
||||
doctypes = [doctypes]
|
||||
_app = app
|
||||
for doctype in doctypes:
|
||||
try:
|
||||
module = frappe.db.get_value("DocType", doctype, "module")
|
||||
|
|
@ -82,13 +83,15 @@ def discover_doctype_tests(doctypes: list[str], runner, app: str, force: bool =
|
|||
|
||||
# Check if the DocType belongs to the specified app
|
||||
doctype_app = frappe.db.get_value("Module Def", module, "app_name")
|
||||
if app and doctype_app != app:
|
||||
raise TestRunnerError(f"DocType {doctype} does not belong to app {app}")
|
||||
elif not app:
|
||||
app = doctype_app
|
||||
if app is None:
|
||||
_app = doctype_app
|
||||
elif doctype_app != app:
|
||||
raise TestRunnerError(
|
||||
f"Mismatch between specified app '{app}' and doctype app '{doctype_app}'"
|
||||
)
|
||||
test_module = frappe.modules.utils.get_module_name(doctype, module, "test_")
|
||||
force and frappe.db.delete(doctype)
|
||||
_add_module_tests(runner, app, test_module)
|
||||
_add_module_tests(runner, _app, test_module)
|
||||
except Exception as e:
|
||||
logger.error(f"Error discovering tests for {doctype}: {e!s}")
|
||||
raise TestRunnerError(f"Failed to discover tests for {doctype}: {e!s}") from e
|
||||
|
|
@ -100,9 +103,15 @@ def discover_module_tests(modules: list[str], runner, app: str) -> "TestRunner":
|
|||
"""Discover tests for the specified test module"""
|
||||
if isinstance(modules, str):
|
||||
modules = [modules]
|
||||
_app = app
|
||||
try:
|
||||
for module in modules:
|
||||
_add_module_tests(runner, app, module)
|
||||
module_app = module.split(".")[0]
|
||||
if app is None:
|
||||
_app = module_app
|
||||
elif app != module_app:
|
||||
raise TestRunnerError(f"Mismatch between specified app '{app}' and module app '{module_app}'")
|
||||
_add_module_tests(runner, _app, module)
|
||||
except Exception as e:
|
||||
logger.error(f"Error discovering tests for {module}: {e!s}")
|
||||
raise TestRunnerError(f"Failed to discover tests for {module}: {e!s}") from e
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class IntegrationTestPreparation:
|
|||
"""Run 'before_tests' hooks"""
|
||||
logger.info(f'Running "before_tests" hooks for {category} tests on app: {app}')
|
||||
for hook_function in frappe.get_hooks("before_tests", app_name=app):
|
||||
logger.info('Running "before_tests" hook function {hook_function}')
|
||||
logger.info(f'Running "before_tests" hook function {hook_function}')
|
||||
frappe.get_attr(hook_function)()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue