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.
This commit is contained in:
Ankush Menat 2021-06-11 16:27:55 +05:30
parent 8b85ac6cf4
commit a164dd0a8c
No known key found for this signature in database
GPG key ID: 8EA82E09BBD13AAF

View file

@ -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):