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.1.tar.gz (185.0 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.1-py3-none-any.whl (203.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_server_testing-4.0.1.tar.gz
  • Upload date:
  • Size: 185.0 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.1.tar.gz
Algorithm Hash digest
SHA256 0979597dee050a2f2047e3b91d8f83d6d9f4ed5f402b34048314fccaf69f6516
MD5 fc5c41d6e0206d229d04d14f24baa4ad
BLAKE2b-256 b34fefbbe3da5681126e9086a1ce0e578e6eeec91be808fbdd79306b4eb01aa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_server_testing-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 566907d7243bbbd3250bf6fa9d3cf8b2143d21e2af7679f24e18a8e5e77a101b
MD5 8b8a9c28e1d598d2010e0295dc65cc8a
BLAKE2b-256 bbad2ca4e9f8c29d9b9f9a9bd888df261b1e3f4af1fec89f07373276cdf6da7b

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