Django test curl
With Django test curl, you can take your test cases and immediately try them against an actual server via the magic of copy-paste!
Django's testing tools come with a great test client you can use to simulate requests against views. Against deployed Django projects, if you want to do simple requests, you would probably use curl. If you want to use the same syntax for both, this is the package for you.
Good places to use this
This was developed to TDD recreating an existing API in Django. If you have a library of curl requests that you need to replicate, this is perfect for that. If you need a portable format to turn test cases into QA automation, this is great for that too.
Bad places to use this
If the .curl(...) syntax requires lots of string formatting, you should stick
to the traditional test client. If the test case isn't copy-pastable, it's
not a good fit. This also means if you use randomness to generate your
requests, you'll lose that extra test coverage.
Installation
$ pip install django-test-curl
Usage
from django_test_curl import CurlClient
class SimpleTest(TestCase):
"""https://docs.djangoproject.com/en/stable/topics/testing/tools/#example"""
def setUp(self):
self.client = CurlClient()
def test_details(self):
response = self.client.curl("""
curl http://localhost:8000/customer/details/
""")
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context['customers']), 5)
If you're using a custom Client, you can use the mixin version:
from django.test import Client
from django_test_curl import CurlClientMixin
class MyClient(CurlClientMixin, Client):
...
We support a subset of curl's functionality. For a full list and examples, see the tests.
- Headers
- GET/POST/PUT/DELETE/etc
- HTTP basic auth
Metadata
Release files for django-test-curl 0.2.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 | |
|---|---|---|---|---|
| django-test-curl-0.2.0.tar.gz | 7.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_test_curl-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.1 kB
Release files / django-test-curl-0.2.0.tar.gz
| Download URL | django-test-curl-0.2.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5fff1933419ed97d91314bddbc9b639d4f34697d9765ffbf8150fa535de35ba
|
|
BLAKE2b-256 checksum How to use checksums |
310ef9cebfa079d897a07fa0e4a49991e63017ed31c327ca7b374c8e92f81feb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|
Release files / django_test_curl-0.2.0-py3-none-any.whl
| Download URL | django_test_curl-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f569c15a8a3e7872805ba3b7137975f822835dd6a81fb52238fccc8d0fb8146
|
|
BLAKE2b-256 checksum How to use checksums |
2824734a8bc73540a2dc4f33c26292617fa9a24d37d8795cec7837ed036001a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|
Security for django-test-curl 0.2.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.