Skip to main content

Server for testing HTTP clients

Project description

https://travis-ci.org/lorien/test_server.png?branch=master

Simple HTTP Server for testing HTTP clients.

Installation

pip install test-server

Usage Example

Example:

from unittest import TestCase
from urllib.request import urlopen
from test_server import TestServer, Response

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):
        token = b'zorro'
        self.server.add_response(Response(data=token))
        data = urlopen(self.server.base_url).read()
        self.assertEqual(data, token)

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

test-server-0.0.33.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file test-server-0.0.33.tar.gz.

File metadata

  • Download URL: test-server-0.0.33.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for test-server-0.0.33.tar.gz
Algorithm Hash digest
SHA256 88fc770a8e1c3d094c14118038ef320f9a531e7dddf6e5f9e104d518432063bb
MD5 a90607961bdc4179efce605622cf8589
BLAKE2b-256 9ece7b4a7458a8b81b0888d0d5ede1c70b4ad232d74941d2bcaee38dda09e70e

See more details on using hashes here.

Supported by

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