Running
- Fail fast / stop after first failure:
pytest -x
- Run from module or directory:
pytest dir/tests/footest.py
,pytest dir/
- Run specific markers:
pytest -m marker
(mark with@pytest.mark.mymarker
) - Drop to pdb on failure:
pytest --pdb
(set breakpoint w/breakpoint()
) - Recreate database using pytest-django:
--create-db
Configuration
pytest.ini
conftest.py
- Use pytest-dotenv to read environment variables from
.env
files - Use pytest-xdist and
pytest -n NUMCPUS
to parallelize test running - Python debugging in VS Code