Skip to main content

A Django test mixin that captures and displays SQL query diffs between test runs, helping to track database-related changes in your tests.

Project description

django-sql-test

A Django test mixin that captures and analyzes SQL queries during tests, with built-in support for displaying diffs between previous and current queries for spotting unexpected changes or regressions.

Usage

Requirements

  • Django >= 4.0
  • Python 3.9 and above.

Installation

Install with:

pip install django-sql-test

Quickstart

In your test.py just import NumNewQueriesMixin and add it as a parent:

from django.test import TestCase
from django_sql_test.utils import NumNewQueriesMixin

class FooTest(NumNewQueriesMixin, TestCase):
    def test_bar(self):
        with self.assertNumQueries(3):
            response = self.client.get(self.url)

        self.assertEqual(response.status_code, 200)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_sql_test-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_sql_test-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file django_sql_test-0.1.1.tar.gz.

File metadata

  • Download URL: django_sql_test-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for django_sql_test-0.1.1.tar.gz
Algorithm Hash digest
SHA256 24ef41cabf6cdfffcfd319f14d441835061b2d76178089c50dffc04b325dfa53
MD5 5eda4c710db2ac6835145b8f4c835458
BLAKE2b-256 abada6df77e1c107347e035e4b34dc274d9702f68b5f47b94fe4a8bb3e512e0e

See more details on using hashes here.

File details

Details for the file django_sql_test-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_sql_test-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for django_sql_test-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72d82babd4564234aa1e942de066c2a948167b9a16d0261958a03d58f0942148
MD5 bbf51e745093fea8cf975ca645808307
BLAKE2b-256 1ef886675bd9ef3b0aa02e1c1313c078c7b000f3c0aa01d9aa3214804a83c4ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page