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
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.32.tar.gz (10.1 kB view hashes)

Uploaded Source

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