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.2.tar.gz (10.3 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.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file django_server_testing-4.0.2.tar.gz.

File metadata

  • Download URL: django_server_testing-4.0.2.tar.gz
  • Upload date:
  • Size: 10.3 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.2.tar.gz
Algorithm Hash digest
SHA256 78f617471b11bf6b0b48cee07f0395db5a3dc02fb585e91efc07b50dcf8f592e
MD5 32e7b69334d0cbf95b9f0994f2f319d2
BLAKE2b-256 e817ddc6fc6b78b2f3334184231a31f93c1d401ab287af235d7c5ca28839fb2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_server_testing-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4f51bdcf039da5051a2aa5bd69cf6e35fc080edc942ba2c355e8581d861f63af
MD5 3d9c81d34f27053bca0b88dd7fe33e27
BLAKE2b-256 0c29e191315b14e180189e72c3647dcc56fccfd96fb60e575bea5f2989ff41cc

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