HTTP response diffing against fixtures for testing
Project description
django-responsediff
I’m pretty lazy when it comes to writing tests for existing code, however, I’m even lazier when it comes to repetitive manual testing action.
This package aims at de-duplicating view tests inside the political-memory itself and to make it reusable for other apps.
It’s pretty much the same as django-dbdiff, except this is for HTTP response.
Response state assertion
When my user tests, he browses the website and checks that everything is rendered fine. This app allows to do high-level checks of HTML rendering.
See responsediff/response.py docstrings for example usage, or use the conveniance mixin:
from responsediff.test import ResponseDiffTestMixin
class MixinTest(ResponseDiffTestMixin, test.TestCase):
def test_admin(self):
self.assertResponseDiffEmpty(test.Client().get('/admin/'))
The above will fail on the first time with FixtureCreated to indicate that it has written responsediff/tests/response_fixtures/MixinTest.test_admin/{content,status_code}. This file is meant to be added to version control. So next time this will run, it will check that response.status_code and response.content is the same, in future version, or in other configurations.
Instead of deleting the fixtures manually before running the tests to regenerate them, just run your tests with FIXTURE_REWRITE=1 environment variable. This will overwrite the fixtures and make the tests look like they passed.
You can also use assertWebsiteSame to crawl your site automatically:
class SiteTest(ResponseDiffTestMixin, test.TestCase):
def test_site(self):
self.assertWebsiteSame()
Requirements
Python 3.10 through 3.14 and Django 4.2 (LTS), 5.2 (LTS), and 6.0 are supported. Install with pip:
pip install django-responsediff
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_responsediff-0.9.0.tar.gz.
File metadata
- Download URL: django_responsediff-0.9.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2e7b8e9e4a421a50d41ccf4c61fd3ae3ce28dcebe3230a4444e34689ceb10e9
|
|
| MD5 |
6a43e071ff3254d00d5589dd2b667e0e
|
|
| BLAKE2b-256 |
5afe6d2b2c7b186c726be431c5987f5317f87ad75cfabb541b134646064a7283
|
File details
Details for the file django_responsediff-0.9.0-py3-none-any.whl.
File metadata
- Download URL: django_responsediff-0.9.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd1d98cea23c3f2366f17e5b3a725866bde8ccffaaec133a045d2b07d91abc17
|
|
| MD5 |
e0923892c76a5cf212e8b209c1da4a97
|
|
| BLAKE2b-256 |
d7a4d78406fd2e8b133bac40584fa66381c84ecfb148202cb2eb58660e4cc85d
|