question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bench run-tests broken

See original GitHub issue

Description of the issue

I wrote a unittest for a DocType named “ITUC Urlaubsvergleich”. I used

bench run-tests --doctype "ITUC Urlaubsvergleich" --skip-test-records --skip-before-tests

and

bench run-tests --doctype "ITUC Urlaubsvergleich"

to start the tests but got some exceptions I don’t understand, see below.

Also all records from the DocType “Leave Application” were deleted.

Context information (for bug reports)

This is what I did before the exceptions happened:

frappe@erpnextthkr:~/frappe-bench$ bench run-tests --doctype "ITUC Urlaubsvergleich"
Testing is disabled for the site!
You can enable tests by entering following command:
bench --site erpnextthkr.schloss.ituc.de set-config allow_tests true
frappe@erpnextthkr:~/frappe-bench$ bench --site erpnextthkr.schloss.ituc.de set-config allow_tests true
frappe@erpnextthkr:~/frappe-bench$ bench run-tests --doctype "ITUC Urlaubsvergleich" --skip-test-records --skip-before-tests

I read the guides https://frappeframework.com/docs/v13/user/en/guides/automated-testing/unit-testing and https://frappeframework.com/docs/v13/user/en/guides/automated-testing/unit-testing. Seems pretty easy to use and straight, but I don’t understand whats going wrong. Output of bench version

erpnext 13.19.0
frappe 13.19.0

Steps to reproduce the issue

  1. Create a new DocType
  2. Create a new unittest.
  3. Run test: bench run-tests --doctype “My new DocType”

Observed result

Exceptions occur, all data from Doctype “Leave Application” is deleted.

Expected result

unittest gets executed without the nonsense mentioned above.

Stacktrace / full error message

frappe@erpnextthkr:~/frappe-bench$ bench run-tests --doctype “ITUC Urlaubsvergleich”

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 583, 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 171, in run_tests_for_doctype
    make_test_records(doctype, verbose=verbose, force=force)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 278, in make_test_records
    make_test_records(options, verbose, force)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 279, in make_test_records
    make_test_records_for_doctype(options, verbose, force)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 329, in make_test_records_for_doctype
    frappe.local.test_objects[doctype] += make_test_objects(doctype, test_module.test_records, verbose, force)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 380, in make_test_objects
    d.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 234, in insert
    self._validate_links()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 837, in _validate_links
    frappe.LinkValidationError)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 439, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 418, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 372, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.LinkValidationError: Could not find Default Holiday List: _Test Holiday List

frappe@erpnextthkr:~/frappe-bench$ bench run-tests --doctype “ITUC Urlaubsvergleich” --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 583, 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 755, in begin
    self.sql("START TRANSACTION")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 126, in sql
    self.check_transaction_status(query)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 265, in check_transaction_status
    raise Exception('This statement can cause implicit commit')
Exception: This statement can cause implicit commit

Additional information

OS version / distribution, Frappe install method, etc. Debian buster

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
e-lobocommented, Jun 27, 2022

try the below image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions - Criterion.rs Documentation
If your benches directory contains source files that are not benchmarks, this could break your build when you update, as Cargo will attempt...
Read more >
V13 develop branch + demo data instance? - ERPNext Forum
trying to install the demo-data for training and development purposes fails. is this supposed to work? bench --site mysite execute erpnext.demo.
Read more >
Bug 343 – utils/bench-packets is broken and asserts - NS-3
It looks like this benchmark utility tries to run tests with and without metadata, which became disallowed at some point (here I think ......
Read more >
berkeleylab / upcxx / issues / #183 - bench/put_flood can't be built by ...
Didn't have access to <upcxx/backend/gasnet/runtime_internal.hpp> when building outside of nobs. The Sep18 runtime refactoring broke the code of this benchmark ...
Read more >
Fuchsia - Testing
You can use runtests --all -d to see the list of tests available in the system. ... For example, to run the kernel's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found