safetydance_django
Django and Django REST framework test steps for safetydance. Drive an APIClient with Given.http.get(...), When.http.post(...) and check the response with Then.http.status_code_is(...).
Install
pip install safetydance-django
This needs Python 3.10 or later and safetydance 0.5.x. The example below also needs pytest and pytest-django, which are not installed as dependencies of safetydance-django.
Example
from django.urls import reverse
import pytest
from safetydance_django.test import *
@pytest.mark.django_db
@test_context
def test_get():
Given.http.get(reverse("simple-list"))
Then.http.status_code_is(200)
assert Http.response.status_code == 200
reverse("simple-list") refers to the example app in this repository’s tests. Substitute the URL name of one of your own views.
The steps are registered at Given.http.* (get, post, put, delete, options, head, login, defaults and so on) when safetydance_django.test or safetydance_django.steps is imported. Import one of them in conftest.py, or star-import safetydance_django.test as above. The steps have no bare names: Given.get raises StepNotFound.
safetydance_django.test exports And, Given, Http, Then, When and test_context. Put @test_context below any @pytest.mark.* decorators and above any @mock.patch decorators. Http.api_client (an APIClient) and Http.response hold the HTTP state of the current test. The client is not called client because @test_context stores pytest fixtures by name, and pytest-django’s client fixture would replace it.
Step modules of your own register their steps only when they are imported, so import them in conftest.py. A plain @step registers a bare name, and a conflict with an existing registration raises when you register.
Documentation
Documentation on the project is at https://dcharbon.gitlab.io/safetydance_django.
Metadata
Release files for safetydance-django 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safetydance_django-0.1.0.tar.gz | 5.3 kB | Without provenance | Details for safetydance_django-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safetydance_django-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for safetydance_django-0.1.0-py3-none-any.whl |
Total release size: 12.3 kB
Release files / safetydance_django-0.1.0.tar.gz
| Download URL | safetydance_django-0.1.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07d836b37b91df31c770004744e0260b783d58a28c1a0a850ae6e8cff7dccf75
|
|
BLAKE2b-256 checksum How to use checksums |
87d75d6ecb607b33af3508b00b9015d9d29f295c6f920da9535863ea1aadb33d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.0
|
Release files / safetydance_django-0.1.0-py3-none-any.whl
| Download URL | safetydance_django-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5176542b804e6d7f24bc58211a4d6a3f9d4d6fc13803da07d3ea287fef1e24a
|
|
BLAKE2b-256 checksum How to use checksums |
1d33819b2b924b9b2edfc678457604489085962d7ed74bed8a85adbc19434124
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.0
|
Security for safetydance-django 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.