Generate performance rapports from your django database performance tests.
Project description
pytest-django-queries
Generate performance rapports from your django database performance tests (inspired by coverage.py).
Usage
Simply install pytest-django-queries
, write your pytest tests and mark any
test that should be counted or use the count_queries
fixture.
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.
Integrating with GitHub
Testing locally
Simply install pytest-django-queries
through pip and run your
tests using pytest
. A report should have been generated in your
current working directory in a JSON file prefixed with .pytest-queries
.
Note: to override the save path, set the PYTEST_QUERIES_SAVE_PATH
environment variable to any given valid path.
Visualising Results
You can generate a table from the tests results by using the show
command:
django-queries show <json file>
You will get something like this to represent the results:
+---------+-------------------------+
| Module | Tests |
+---------+-------------------------+
| module1 | +-----------+---------+ |
| | | Test Name | Queries | |
| | +-----------+---------+ |
| | | test1 | 0 | |
| | +-----------+---------+ |
| | | test2 | 1 | |
| | +-----------+---------+ |
+---------+-------------------------+
| module2 | +-----------+---------+ |
| | | Test Name | Queries | |
| | +-----------+---------+ |
| | | test1 | 123 | |
| | +-----------+---------+ |
+---------+-------------------------+
| module3 | |
+---------+-------------------------+
Exporting the results (HTML)
For a nicer presentation, use the html
command, to export the results as HTML.
django-queries html <json file> > results.html
Comparing results
Development
First of all, clone the project locally. Then, install it using the below command.
./setup.py develop
After that, you need to install the development requirements. For that, run the below command.
pip install -e .[dev]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytest-django-queries-1.0.0.dev1.tar.gz
.
File metadata
- Download URL: pytest-django-queries-1.0.0.dev1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b49aaecef6cd27d1062ac1f4f43f20b1261272034111a2ee1ee27ab8883bf315 |
|
MD5 | ca91f4140b9a880474aed624b488dfc1 |
|
BLAKE2b-256 | afd71530be549e64a03e679f619a9132a2cc4363d8cca2199de35632c614e7f1 |