Skip to main content

Server to test HTTP clients

Project description

https://travis-ci.org/lorien/test_server.png?branch=master https://ci.appveyor.com/api/projects/status/o3qhdh1gprcu1x1x https://coveralls.io/repos/lorien/test_server/badge.svg?branch=master https://api.codacy.com/project/badge/Grade/3ff9f3ebf06d4b7f8809b264837eac43

HTTP Server to test HTTP clients.

Installation

pip install test-server

Usage Example

Example:

from unittest import TestCase
try:
    from urllib import urlopen
except ImportError:
    from urllib.request import urlopen
from test_server import TestServer

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.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.28.dev0.tar.gz (12.9 kB view details)

Uploaded Source

File details

Details for the file test-server-0.0.28.dev0.tar.gz.

File metadata

File hashes

Hashes for test-server-0.0.28.dev0.tar.gz
Algorithm Hash digest
SHA256 1d2aeba592462a8b8f73b5c0399e0882cf4a7bfab3906c4ab94ec91f21022e45
MD5 6436cdd8e5f286695d4087ce8361dbe2
BLAKE2b-256 8d4254f2d8e03c10266fb903afd65f6888c32e26572838560a9585ff147b9c6b

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