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
Release history Release notifications | RSS feed
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)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e442141b8c24b340b5ae8da69ec7e40255e60a919adc3d8cb16425a134a1a35 |
|
MD5 | 5948813d83addae6e56ab2b5176104cf |
|
BLAKE2b-256 | 53ae43c739dfaf4aa3b2ca5a576aec46f37122e4a4fe4f27253129d4da61fede |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 642e82064717a3587daf563d42a2c3495cc2af187fdc32de7cc30a6dd69459af |
|
MD5 | 3281cd9bcaca1e7f2583bb41acb00797 |
|
BLAKE2b-256 | 8de71b0aea8bf4874dfef8e9276b8c3a731c6cbc373c498c15d3db4b035a1ae3 |