I am using pytest to run my django tests and was trying to speed them up by running them in parallel. I tried modifying my database name using the enviroment variable PYTEST_XDIST_WORKER but my tests still cannot access the database.
How do I need to set my database settings in my django configuration so that the parallel databases are created and used.
db_suffix = env.str("PYTEST_XDIST_WORKER", "")
DATABASES["default"]["NAME"] = f"""{DATABASES["default"]["NAME"]}_{db_suffix}"""
pytest.ini
[pytest]
addopts = --ds=config.settings.test --create-db
python_files = tests.py test_*.py
norecursedirs = node_modules
env_files=
.env.tests
command to run tests: pytest -n 4
Error: database "auto_tests_gw0" does not exist