From 551be4f6ab886b33ed52fb22c405e6ddbb76b971 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 15 Apr 2025 18:28:21 +0200 Subject: [PATCH] fix: Clear site test records log before running test Not sure if this was intentional - there is no documentation as far as i can tell --- frappe/commands/testing.py | 7 ++++--- frappe/tests/utils/generators.py | 2 +- frappe/utils/install.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frappe/commands/testing.py b/frappe/commands/testing.py index 10dd126ec3..4acc05c9f6 100644 --- a/frappe/commands/testing.py +++ b/frappe/commands/testing.py @@ -11,8 +11,6 @@ from frappe.commands import get_site, pass_context from frappe.utils.bench_helper import CliCtxObj if TYPE_CHECKING: - import unittest - from frappe.testing import TestRunner @@ -46,6 +44,9 @@ def main( discover_module_tests, ) from frappe.testing.environment import _cleanup_after_tests, _initialize_test_environment + from frappe.tests.utils.generators import _clear_test_log + + _clear_test_log() if debug and not debug_exceptions: debug_exceptions = (Exception,) @@ -275,7 +276,7 @@ def run_tests( site = get_site(context) frappe.init(site) - allow_tests = frappe.get_conf().allow_tests + allow_tests = frappe.conf.allow_tests if not (allow_tests or os.environ.get("CI")): click.secho("Testing is disabled for the site!", bold=True) diff --git a/frappe/tests/utils/generators.py b/frappe/tests/utils/generators.py index b49488ea81..b92364ea50 100644 --- a/frappe/tests/utils/generators.py +++ b/frappe/tests/utils/generators.py @@ -414,7 +414,7 @@ class TestRecordManager: temp_file.replace(self.log_file) -def _after_install_clear_test_log(): +def _clear_test_log(): log_file_path = frappe.get_site_path(PERSISTENT_TEST_LOG_FILE) if os.path.exists(log_file_path): os.remove(log_file_path) diff --git a/frappe/utils/install.py b/frappe/utils/install.py index 0e65258a45..195e9a4c0a 100644 --- a/frappe/utils/install.py +++ b/frappe/utils/install.py @@ -48,9 +48,9 @@ def after_install(): frappe.db.set_single_value("System Settings", "setup_complete", 0) # clear test log - from frappe.tests.utils.generators import _after_install_clear_test_log + from frappe.tests.utils.generators import _clear_test_log - _after_install_clear_test_log() + _clear_test_log() add_standard_navbar_items()