Skip to main content

Add unit tests to your http clients

Project description

HTTP testing inspired by golang’s httptest package.

Usage

import unittest
import urllib.request

import httptest

class TestHTTPServer(httptest.Handler):

    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/plain")
        self.end_headers()
        self.wfile.write(bytes("what up", "utf-8"))

class TestHTTPTestMethods(unittest.TestCase):

    @httptest.Server(TestHTTPServer)
    def test_call_response(self, ts=httptest.NoServer()):
        with urllib.request.urlopen(ts.url()) as f:
            self.assertEqual(f.read().decode('utf-8'), "what up")

if __name__ == '__main__':
    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

httptest-0.0.7.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

httptest-0.0.7-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file httptest-0.0.7.tar.gz.

File metadata

  • Download URL: httptest-0.0.7.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for httptest-0.0.7.tar.gz
Algorithm Hash digest
SHA256 5e442141b8c24b340b5ae8da69ec7e40255e60a919adc3d8cb16425a134a1a35
MD5 5948813d83addae6e56ab2b5176104cf
BLAKE2b-256 53ae43c739dfaf4aa3b2ca5a576aec46f37122e4a4fe4f27253129d4da61fede

See more details on using hashes here.

File details

Details for the file httptest-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: httptest-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for httptest-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 642e82064717a3587daf563d42a2c3495cc2af187fdc32de7cc30a6dd69459af
MD5 3281cd9bcaca1e7f2583bb41acb00797
BLAKE2b-256 8de71b0aea8bf4874dfef8e9276b8c3a731c6cbc373c498c15d3db4b035a1ae3

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