Trying to run Unit tests but error

Trying to run Unit tests with bench run-tests but error:

line 160, in get_doctype_module
    return frappe.cache().get_value("doctype_modules", make_modules_dict)[doctype]
KeyError: u'Integration Service'

Any Ideas?


Any Ideas?

To copy and paste the complete traceback is always a good start

@clarkej, Sorry.
I took similar error today:

--- erpnext_web ping statistics ---
sut                       | 10 packets transmitted, 10 packets received, 0% packet loss
sut                       | round-trip min/avg/max = 0.082/0.095/0.164 ms
sut                       | Executing erpnext_ocr app tests...
sut                       | Traceback (most recent call last):
sut                       |   File "/usr/local/lib/python3.7/", line 193, in _run_module_as_main
sut                       |     "__main__", mod_spec)
sut                       |   File "/usr/local/lib/python3.7/", line 85, in _run_code
sut                       |     exec(code, run_globals)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 97, in <module>
sut                       |     main()
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 18, in main
sut                       |     click.Group(commands=commands)(prog_name='bench')
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 764, in __call__
sut                       |     return self.main(*args, **kwargs)
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 717, in main
sut                       |     rv = self.invoke(ctx)
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 1137, in invoke
sut                       |     return _process_result(sub_ctx.command.invoke(sub_ctx))
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 1137, in invoke
sut                       |     return _process_result(sub_ctx.command.invoke(sub_ctx))
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 956, in invoke
sut                       |     return ctx.invoke(self.callback, **ctx.params)
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 555, in invoke
sut                       |     return callback(*args, **kwargs)
sut                       |   File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/", line 17, in new_func
sut                       |     return f(get_current_context(), *args, **kwargs)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 25, in _func
sut                       |     ret = f(frappe._dict(ctx.obj), *args, **kwargs)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 419, in run_tests
sut                       |     ui_tests = ui_tests, doctype_list_path = doctype_list_path, failfast=failfast)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 70, in main
sut                       |     ret = run_all_tests(app, verbose, profile, ui_tests, failfast=failfast)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 112, in run_all_tests
sut                       |     test_suite, ui_tests)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 240, in _add_test
sut                       |     make_test_records(doctype, verbose)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 251, in make_test_records
sut                       |     for options in get_dependencies(doctype):
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 272, in get_dependencies
sut                       |     module, test_module = get_modules(doctype)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 263, in get_modules
sut                       |     test_module = load_doctype_module(doctype, module, "test_")
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 180, in load_doctype_module
sut                       |     module = get_doctype_module(doctype)
sut                       |   File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 174, in get_doctype_module
sut                       |     return frappe.cache().get_value("doctype_modules", make_modules_dict)[doctype]
sut                       | KeyError: '<name of doctype>'

version of frappe: 11
os: alpine

Please specify the command line you use to run the tests - of these options to run the tests, do any of them run to completion?

This is a custom app - what is the url for this repository?

bench --site [sitename] run-tests --app erpnext_ocr

# run tests for the Task doctype
bench --site [sitename] run-tests --doctype "Task"

# run a test using module path
bench --site [sitename] run-tests --module frappe.tests.test_api


You might also try this:

frappe@erpnext:~/frappe-bench$ find apps/erpnext_ocr -name '*.pyc' | xargs rm -f

Perhaps a custom app requires a Module Def but that is missing here - inspect tabModule Def for clues?

I used this command:
bench --site [sitename] run-tests --app erpnext_ocr