Gentlemen,
I seem to have an issue with running tests. I have this simple test-class for DocType “Email Log” in erpituc/erpituc/erpituc/doctype/email_log/test_email_log.py
:
class TestEmailLog(unittest.TestCase):
def setUp(self) -> None:
print("setUp called")
def test_something(self):
self.assertTrue("All is well")
But when i run
frappe@erpnextthkr:~/frappe-bench$ bench setup requirements --dev
frappe@erpnextthkr:~/frappe-bench$ bench --site erpnextthkr.schloss.ituc.de set-config allow_tests true
frappe@erpnextthkr:~/frappe-bench$ bench run-tests --doctype "Email Log" --skip-test-records --skip-before-tests
This exception happens:
frappe@erpnextthkr:~/frappe-bench$ bench run-tests --doctype "Email Log" --skip-test-records --skip-before-tests
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 104, in <module>
main()
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 19, in main
click.Group(commands=commands)(prog_name='bench')
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 27, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 588, in run_tests
ui_tests=ui_tests, doctype_list_path=doctype_list_path, failfast=failfast)
File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 70, in main
ret = run_tests_for_doctype(doctype, verbose, tests, force, profile, failfast=failfast, junit_xml_output=junit_xml_output)
File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 174, in run_tests_for_doctype
return _run_unittest(modules, verbose=verbose, tests=tests, profile=profile, failfast=failfast, junit_xml_output=junit_xml_output)
File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 186, in _run_unittest
frappe.db.begin()
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 769, in begin
self.sql("START TRANSACTION")
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 124, in sql
self.check_transaction_status(query)
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 263, in check_transaction_status
raise Exception('This statement can cause implicit commit')
Exception: This statement can cause implicit commit
So how to use “bench run-tests”?
I also searched the forum and found this (Tutorial: ERPNext Python Testing), but it didn’t help me with this particular error.