Skip to main content

wsgiref-fake

In-process WSGI test doubles: fake sockets and a minimal server harness so you can exercise HTTP (and optionally WebSocket) applications without binding a real port or talking over the network.

Useful for fast, deterministic tests against code built on wsgiref and similar stacks.

Requirements

  • Python 3.10 or newer
  • Runtime dependency: six (Python 2/3 compatibility helpers used in this library)

Installation

pip install wsgiref-fake

With uv:

uv add wsgiref-fake

Optional extras

Extra Purpose
gevent Gevent-based WebSocket client helpers
ws4py Integration helpers around ws4py
pip install "wsgiref-fake[gevent]"
pip install "wsgiref-fake[ws4py]"

Quick start (HTTP)

Wire your WSGI app to an in-process server, then drive it with HTTPClient:

from wsgiref_fake.http.client import HTTPClient
from wsgiref_fake.server import make_server


def app(environ, start_response):
    start_response("200 OK", [("Content-Type", "text/plain")])
    return [b"Hello World"]


server = make_server(app=app)
client = HTTPClient(server=server)

response = client.request(method="GET", path="/")
assert response.status == 200
body = response.read()

HTTPClient.request accepts method, path, optional json (sets Content-Type and body), and optional headers.

Why this exists

  • No listening socket — tests stay hermetic and parallel-friendly.
  • Same WSGI surface as production-oriented wsgiref servers, without TCP overhead.
  • WebSocket-related helpers are available when you install the optional dependency groups above.

Development

Clone the repository, then install the project with dev dependencies:

uv sync

Run the test suite:

uv run pytest

Lint and format the whole tree:

uv run ruff check .
uv run ruff format .

Contributing

Issues and pull requests are welcome. Please run tests before opening a PR.

License

This project is licensed under the MIT License.

Metadata

Release files for wsgiref-fake 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wsgiref-fake 1.0.4
File Size Uploaded Provenance
wsgiref_fake-1.0.4.tar.gz 8.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for wsgiref-fake 1.0.4
File Interpreter ABI Platform
wsgiref_fake-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / wsgiref_fake-1.0.4.tar.gz

Download URL wsgiref_fake-1.0.4.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
282a20c91de19383409be0140ba4dc79e45136bdbd0422b4b8a71078110698e1
BLAKE2b-256 checksum
How to use checksums
6e186fe20ea23a883bf96b424e8f693cd96e04fbed363ca9ad020298cdbfe511
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / wsgiref_fake-1.0.4-py3-none-any.whl

Download URL wsgiref_fake-1.0.4-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e932c14c3208af5d1d5c6e9061059ad499ac2e010c59c0bbd2a67e8069524942
BLAKE2b-256 checksum
How to use checksums
8586e750d87cba5c8cdb5d0566a527c26785919d545253c0eb1c58d88cb57177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for wsgiref-fake 1.0.4

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.

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page