No project description provided
Project description
Documentation for django_server_testing
Simple http server tester using Django
Installation
Run pip install django-server-testing
Usage Example
from unittest import TestCase
import unittest
from urllib.request import urlopen
from django_server_testing import TestServer, Response, HttpHeaderStorage
class UrllibTestCase(TestCase):
@classmethod
def setUpClass(cls):
cls.server = TestServer()
cls.server.start()
@classmethod
def tearDownClass(cls):
cls.server.stop()
def setUp(self):
self.server.reset()
def test_get(self):
self.server.add_response(
Response(
data=b"hello",
headers={"foo": "bar"},
)
)
self.server.add_response(Response(data=b"zzz"))
url = self.server.get_url()
info = urlopen(url)
self.assertEqual(b"hello", info.read())
self.assertEqual("bar", info.headers["foo"])
info = urlopen(url)
self.assertEqual(b"zzz", info.read())
self.assertTrue("bar" not in info.headers)
unittest.main()
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
django_server_testing-4.0.4.tar.gz
(101.2 kB
view details)
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_server_testing-4.0.4.tar.gz.
File metadata
- Download URL: django_server_testing-4.0.4.tar.gz
- Upload date:
- Size: 101.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7902e3c1df9d7892cc3148613d138c637dac4db6af97bf8d82d12d91fcb20d1b
|
|
| MD5 |
e86653d9825acc7670e8a8dc812ae321
|
|
| BLAKE2b-256 |
eec3f737090534301faa079c701dd9bdb2e51e7aa2850a6f640c5a1e4503c383
|
File details
Details for the file django_server_testing-4.0.4-py3-none-any.whl.
File metadata
- Download URL: django_server_testing-4.0.4-py3-none-any.whl
- Upload date:
- Size: 101.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bcd4780096309b3cef22074aee6c0cb8e219715d14e5d0e8efc114e6d7dcf7b
|
|
| MD5 |
306a0db5c996d8b8b5bf8fd3244c1dd2
|
|
| BLAKE2b-256 |
1a2210b54cf12da70b813b9eaa023a704f9b7cb4ad2e601d960fd5c484edc5f7
|