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.3.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.3.tar.gz.
File metadata
- Download URL: django_server_testing-4.0.3.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 |
713edd0abfa4b54f03fe269386139ffdf1d62d1d9cb7a02beed44314eda085cb
|
|
| MD5 |
05866bd93e2a4927f267056429480ba0
|
|
| BLAKE2b-256 |
db3064ee2f5d46bf024c9056a5a1a33c7537139913857ee4c1c911cd518f91e8
|
File details
Details for the file django_server_testing-4.0.3-py3-none-any.whl.
File metadata
- Download URL: django_server_testing-4.0.3-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 |
1d3408b97a6b631ded88e85e4699df85d08956790fb84a00ca2870f4c7904319
|
|
| MD5 |
fde5b4edcaebe12e489a87949a55f689
|
|
| BLAKE2b-256 |
9d90772a5f6effd10d1b319b830960e88dc87be0e6ba4e44d5b45c3f76cdf034
|