Generate performance reports from your django database performance tests.
Maintained. Last release 9 months ago, commits in 3 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install pytest-django-queriespytest-django-queries
Generate performance reports from your django database performance tests (inspired by coverage.py).
Usage
Install pytest-django-queries, write your pytest tests and mark any
test that should be counted or use the count_queries fixture.
Note: to use the latest development build, use pip install --pre pytest-django-queries
import pytest
@pytest.mark.count_queries
def test_query_performances():
Model.objects.all()
# Or...
def test_another_query_performances(count_queries):
Model.objects.all()
Each test file and/or package is considered as a category. Each test inside a "category" compose its data, see Visualising Results for more details.
You will find the full documentation here.
Recommendation when Using Fixtures
You might end up in the case where you want to add fixtures that are generating queries
that you don't want to be counted in the results–or simply, you want to use the
pytest-django plugin alongside of pytest-django-queries, which will generate
unwanted queries in your results.
For that, you will want to put the fixture as the last fixture to execute.