diff --git a/commitlint.config.js b/commitlint.config.js index 09de8b8272..0c582f542f 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -19,6 +19,7 @@ module.exports = { "revert", "style", "test", + "deprecate", // deprecation decision ], ], }, diff --git a/frappe/parallel_test_runner.py b/frappe/parallel_test_runner.py index e840f1455c..2f832045b8 100644 --- a/frappe/parallel_test_runner.py +++ b/frappe/parallel_test_runner.py @@ -85,6 +85,13 @@ class ParallelTestRunner: print("running tests from", "/".join(file_info)) return + from frappe.deprecation_dumpster import deprecation_warning + + deprecation_warning( + "2024-11-13", + "v17", + "Setting the test environment user to 'Administrator' by the test runner is deprecated. The UnitTestCase now ensures a consistent user environment on set up and tear down at the class level. ", + ) frappe.set_user("Administrator") path, filename = file_info module = self.get_module(path, filename) diff --git a/frappe/tests/classes/unit_test_case.py b/frappe/tests/classes/unit_test_case.py index 8ae656f5eb..45b8e56963 100644 --- a/frappe/tests/classes/unit_test_case.py +++ b/frappe/tests/classes/unit_test_case.py @@ -49,6 +49,10 @@ class UnitTestCase(unittest.TestCase, BaseTestCase): super().setUpClass() cls.doctype = _get_doctype_from_module(cls) cls.module = frappe.get_module(cls.__module__) + # Test Environment + frappe.set_user("Administrator") + # Test Environment (cleanup) + cls.addClassCleanup(frappe.set_user, "Administrator") cls._unit_test_case_class_setup_done = True def assertQueryEqual(self, first: str, second: str) -> None: