Can't run-tests locally (dev and prod stacks)

Happy new year!

Using the dev docker containers stack locally:

bench --site development.localhost list-apps
frappe 15.x.x-develop () develop
erpnext 15.x.x-develop () develop

bench --site development.localhost run-tests
Failed to discover tests for [‘frappe’, ‘erpnext’]: No module named ‘responses’

I read Unit testing framework is down ? · Issue #27584 · frappe/frappe · GitHub which is the same issue, the response is to use a local server … which was the case of the OP, and is the same setup I run.
Where is this responses module?

EDIT:

Same issue on a freshly installed prod docker setup (12 containers):

Commands restricted in prodution container, Read FAQ before you proceed: https://frappe.fyi/ctr-faq
frappe@0615204a1534:~/frappe-bench$ ls
apps  config  env  logs  patches.txt  sites
frappe@0615204a1534:~/frappe-bench$ bench --site frontend run-tests
Testing is disabled for the site!
You can enable tests by entering following command:
bench --site frontend set-config allow_tests true
frappe@0615204a1534:~/frappe-bench$ bench --site frontend set-config allow_tests true
frappe@0615204a1534:~/frappe-bench$ bench --site frontend run-tests
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 790, in run_tests
    ret = frappe.test_runner.main(
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 111, in main
    ret = run_all_tests(app, verbose, profile, failfast=failfast, junit_xml_output=junit_xml_output)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 162, in run_all_tests
    _add_test(app, path, filename, verbose, test_suite)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/test_runner.py", line 313, in _add_test
    module = importlib.import_module(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/webhook/test_webhook.py", line 6, in <module>
    import responses
ModuleNotFoundError: No module named 'responses'

I forgot to say: yes, I checked the box:

on prod, I also tried to force re-install erpnext and run-tests again:
frappe@0615204a1534:~/frappe-bench$ bench --site frontend list-apps

frappe 15.51.0 UNVERSIONED
erpnext 15.47.1 UNVERSIONED

These are python modules, not Frappe, ah!

ΟΚ, after almost an hour spent on this:

dev stack:
bench --site development.localhost run-tests
AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue'

let’s forget it and reinstall:
bench --site development.localhost reinstall
→ frappe.exceptions.LinkValidationError: Could not find DocType: Sales Order
so now, it’s deeply broken!

prod stack:

AssertionError: 'mieamnusnu' is not false

----------------------------------------------------------------------
Ran 3145 tests in 2810.281s

FAILED (failures=47, errors=558, skipped=31)

and bench --site frontend reinstall is stall for now. Wait and see!

So, what’s the setup to populate a company and business in erpnext?

Perhaps not optimal

docker compose exec backend bench drop-site frontend

docker compose -f pwd.yml up -d

Also tried:

docker compose exec backend bench --site frontend set-config allow_tests true

and

docker compose exec backend bench --site frontend run-tests --app erpnext

result

frappe.testing.discovery.TestRunnerError: Failed to discover tests for [‘erpnext’]:

This worked for me on Gitlab .gitlab-ci.yml · main · castlecraft / Frappe Utils · GitLab

Thank you @revant_one
Unfortunately, docker-compose -f gitlab-ci.yml up -d throws: services must be a mapping
No CI in my case.
Also I notice you run-tests --app frappe_utils and dev_utils, but I want to run-tests --app erpnext to populate the website with demo data.

If you’re looking for demo data then it gets created during setup wizard if you choose to populate demo data. Check if that works for your demo?

Unfortunately, checking the box didn’t create any records, I tried on multiple stack installs.
run-test did create some data for ‘Wind Power LLC’ before crashing in blazing flames, usually after 1800+ seconds, with various error messages.
One time, the reinstall command couldn’t even reinstall anything, I had to start from scratch.

Is there a way to import all ‘Wind Power LLC’ demo data in a fresh prod or dev stack?
Even a SQL export I could import through direct access to MariaDB.

The setup wizard option worked here OOB . Though not using a dev stack.

I bench init on my desktop to run everything on the host, without docker involved, and run-tests works.
I now have 14 companies with invoices, etc…
Weird, Wind Power LLC is not one of them. Maybe one of the tests was to delete it?
Tests ended up without crashing. 1699 tests populated the ERP.
But checking the checkbox alone to get demo app after reinstall wasn’t working, I tried twice.

Still sad that you cannot have a proper demo to show on a prod container.

Take backup of the demo db and restore anywhere you need demo data. May need to run bench --site all migrate

That’s waht I thought too!
I’m just too new to Frappé to be sure which tables to export, and which one could break the containers.