Skip to main content

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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_server_testing-4.0.4-py3-none-any.whl (101.5 kB view details)

Uploaded Python 3

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

Hashes for django_server_testing-4.0.4.tar.gz
Algorithm Hash digest
SHA256 7902e3c1df9d7892cc3148613d138c637dac4db6af97bf8d82d12d91fcb20d1b
MD5 e86653d9825acc7670e8a8dc812ae321
BLAKE2b-256 eec3f737090534301faa079c701dd9bdb2e51e7aa2850a6f640c5a1e4503c383

See more details on using hashes here.

File details

Details for the file django_server_testing-4.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_server_testing-4.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6bcd4780096309b3cef22074aee6c0cb8e219715d14e5d0e8efc114e6d7dcf7b
MD5 306a0db5c996d8b8b5bf8fd3244c1dd2
BLAKE2b-256 1a2210b54cf12da70b813b9eaa023a704f9b7cb4ad2e601d960fd5c484edc5f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page