Merge pull request #28448 from blaggacao/fix/test-environment-user-idempotency
fix(testing)!: ensure idempotency on the test environment user
This commit is contained in:
commit
3dff39946d
3 changed files with 12 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ module.exports = {
|
|||
"revert",
|
||||
"style",
|
||||
"test",
|
||||
"deprecate", // deprecation decision
|
||||
],
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue