Documentation for test_server package
Simple HTTP Server for testing HTTP clients.
Community
You are welcome to join Telegram chat groups to talk about web scraping and data processing: @grablab (English), @grablab_ru (Russian).
Installation
Run pip install -U test_server
Usage Example
from unittest import TestCase
import unittest
from urllib.request import urlopen
from test_server import TestServer, Response, HttpHeaderStorage
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):
self.server.add_response(
Response(
data=b"hello",
headers={"foo": "bar"},
)
)
self.server.add_response(Response(data=b"zzz"))
url = self.server.get_url()
info = urlopen(url)
self.assertEqual(b"hello", info.read())
self.assertEqual("bar", info.headers["foo"])
info = urlopen(url)
self.assertEqual(b"zzz", info.read())
self.assertTrue("bar" not in info.headers)
unittest.main()
Metadata
Release files for test-server 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| test_server-0.1.0.tar.gz | 17.3 kB | Without provenance | Details for test_server-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| test_server-0.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for test_server-0.1.0-py2.py3-none-any.whl |
Total release size: 30.1 kB
Release files / test_server-0.1.0.tar.gz
| Download URL | test_server-0.1.0.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b037fb0ceb7956ce287ddfbe6a42ee35c19a581d510806842ff003110f17330
|
|
BLAKE2b-256 checksum How to use checksums |
5c7e1c6948cfa2c81b6b20477f6993f548c885b6f0d3777f4457a3f8f7ceffc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / test_server-0.1.0-py2.py3-none-any.whl
| Download URL | test_server-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
dbc9f0e56dc44bba145a68e4b0bba032216fc86b4271c1d1f3a019e938b9b067
|
|
BLAKE2b-256 checksum How to use checksums |
f6da460c57a7db4a83f63b28218f19db76d17088b70993234a7c0695db0f8f5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Security for test-server 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.