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.iniconftest.py- Use pytest-dotenv to read environment variables from
.envfiles - Use pytest-xdist and
pytest -n NUMCPUSto parallelize test running - Python debugging in VS Code