Hi,
I’m looking at unit testing module (to reopen a PR missing testing file) and plan to add my method test_item_search()
in test_item.py because I need test items but the run-tests command crashes on last develop branch (some test datas seem not created)
bench run-tests --doctype "item"
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
“main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/britlog/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/britlog/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/britlog/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/britlog/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/britlog/frappe-bench/apps/frappe/frappe/commands/utils.py”, line 319, in run_tests
ui_tests = ui_tests)
File “/home/britlog/frappe-bench/apps/frappe/frappe/test_runner.py”, line 57, in main
ret = run_tests_for_doctype(doctype, verbose, tests, force, profile)
File “/home/britlog/frappe-bench/apps/frappe/frappe/test_runner.py”, line 130, in run_tests_for_doctype
make_test_records(doctype, verbose=verbose, force=force)
File “/home/britlog/frappe-bench/apps/frappe/frappe/test_runner.py”, line 223, in make_test_records
make_test_records(options, verbose, force)
File “/home/britlog/frappe-bench/apps/frappe/frappe/test_runner.py”, line 224, in make_test_records
make_test_records_for_doctype(options, verbose, force)
File “/home/britlog/frappe-bench/apps/frappe/frappe/test_runner.py”, line 266, in make_test_records_for_doctype
frappe.local.test_objects[doctype] += test_module._make_test_records(verbose)
File “/home/britlog/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/test_account.py”, line 65, in make_test_records
} for account_name, parent_account, is_group, account_type, currency in accounts])
File “/home/britlog/frappe-bench/apps/frappe/frappe/test_runner.py”, line 311, in make_test_objects
d.insert()
File “/home/britlog/frappe-bench/apps/frappe/frappe/model/document.py”, line 192, in insert
self.run_before_save_methods()
File “/home/britlog/frappe-bench/apps/frappe/frappe/model/document.py”, line 772, in run_before_save_methods
self.run_method(“validate”)
File “/home/britlog/frappe-bench/apps/frappe/frappe/model/document.py”, line 666, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/britlog/frappe-bench/apps/frappe/frappe/model/document.py”, line 887, in composer
return composed(self, method, *args, **kwargs)
File “/home/britlog/frappe-bench/apps/frappe/frappe/model/document.py”, line 870, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/britlog/frappe-bench/apps/frappe/frappe/model/document.py”, line 660, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/britlog/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/account.py”, line 33, in validate
self.validate_parent()
File “/home/britlog/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/account.py”, line 48, in validate_parent
throw((“Account {0}: Parent account {1} does not exist”).format(self.name, self.parent_account))
File “/home/britlog/frappe-bench/apps/frappe/frappe/init.py”, line 319, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/britlog/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/britlog/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
frappe.exceptions.ValidationError: Account _Test Bank - _TC: Parent account Bank Accounts - _TC doesn’t exist