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.5.tar.gz (28.2 MB 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.5-py3-none-any.whl (28.2 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_server_testing-4.0.5.tar.gz
  • Upload date:
  • Size: 28.2 MB
  • 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.5.tar.gz
Algorithm Hash digest
SHA256 824cbad9657684f0b2b728b2814fdfe3f69d8fd90817f6de762b7dc5b05065c7
MD5 abbe2d76c9a4545d28a53080fde85780
BLAKE2b-256 2089e5dc578efecd386ef1ab4fe80924b0cd9d316d41a30398a17d7fd2392e3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_server_testing-4.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 28e105c9aabdc1959f073b94a6a38f8522326ae6921588a1c1e83ddbfd854b26
MD5 e949acc6787c0852aed9cdd4921b72fe
BLAKE2b-256 ae2fab113fd9c8e1ccef6431acf9722e0ccb63329cff84b916ebf8c324852437

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