Overview
Setup
First create a virtual environment
python3 -m venv .venv
source .venv/bin/activateOR w/ uv
uv venv
source .venv/bin/activateThen install project dependencies:
pip install -r requirements.txt
pip install pytest pytest-asyncioRunning Tests
Then run the specific test file…
Verbose Mode
pytest tests/test_tag_search.py -vRun only Unit Tests
pytest -k "not integration and not slow" -qRun all tests except slow
pytest -m "not slow" -vRun only integration tests
pytest -m integration -vRun a single test function inside the test file
pytest tests/test_tag_search.py::TestTagSearchBasics::test_single_tag_match -qReport Options
3 Test Reporting libraries you could use:
pytest-htmlpytest-json-reportpytest-cov
Console w/ verbose + show locals options
- Command:
pytest tests/test_tag_search.py -vv -r a --showlocals - Shows per-test output, full summary (fails, xfails, skips, warnings).
Show slowest tests
- Command:
pytest tests/test_tag_search.py --durations=10 - Shows the top 10 slowest tests (use 0 for all).
Additional Libraries
- JUnit XML (CI friendly)
- Command: pytest —junitxml=reports/junit.xml
- Produces
reports/junit.xmlconsumable by CI systems.
- HTML (human-friendly)
- Command: pytest —html=reports/report.html —self-contained-html
- Produces
reports/report.htmlyou can open in a browser.
- JSON programmatic report
- Command: pytest —json-report —json-report-file=reports/report.json
- Produces
reports/report.jsonfor automated parsing.