From a164dd0a8cc3b14282be38e9e61ec2acb9622c1a Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 11 Jun 2021 16:27:55 +0530 Subject: [PATCH] fix: test failure due to uncommited transaction Steps to reproduce: - Create a fresh new site with Frappe - Add and install a new app. - Add basic test_file.py anywhere in module. - Run the single using test with bench command: `bench --module module.dotted.path --test testname` The test will not run and complain about implicit commit. - root cause: test runner makes changes to DB but does not commit. e.g. disabling of scheduler on L57. Note: this is not reproducible in FF or when ERPNext is installed because in many places of "test process" somethng else commits the changes like `before_tests` hook, which usually isn't present in new apps. --- frappe/test_runner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/frappe/test_runner.py b/frappe/test_runner.py index 1f99e55fb8..0c30fbbd00 100644 --- a/frappe/test_runner.py +++ b/frappe/test_runner.py @@ -175,6 +175,7 @@ def run_tests_for_module(module, verbose=False, tests=(), profile=False, junit_x for doctype in module.test_dependencies: make_test_records(doctype, verbose=verbose) + frappe.db.commit() return _run_unittest(module, verbose=verbose, tests=tests, profile=profile, junit_xml_output=junit_xml_output) def _run_unittest(modules, verbose=False, tests=(), profile=False, junit_xml_output=False):