skillfed

pook

HTTP traffic mocking and expectations made easy

pook v2.1.6 270.3K downloads/30d#8,237 on PyPI374
Permissive license MIT Active released

What it is and what it does

pook is a Python HTTP mocking library that intercepts traffic from popular HTTP clients and lets you define mock responses using a fluent, chainable API. It works as a decorator, context manager, or direct function call, and supports matching on any HTTP primitive (URL, method, headers, body, query params) with full regex capability. The library includes first-class JSON and XML support via jsonschema and xmltodict, JSON Schema body matching, and can simulate raised errors or network delays.

You can use pook in both unit tests and runtime environments, with configurable mock lifetimes (volatile, persistent, or TTL-limited). It ships with a built-in mock engine supporting multiple HTTP clients, but also supports pluggable third-party engines. With only 3 small dependencies (furl, jsonschema, xmltodict) and no compiled requirements, it installs cleanly and works on Python 3.10+ (CPython and PyPy).

Use it for:

  • Mock external API responses in unit tests without making real network calls to third-party services.
  • Test error handling by returning specific HTTP status codes and error payloads from mock endpoints.
  • Validate request matching logic by asserting that code sends correct headers, query params, or body.
  • Test multiple HTTP clients against the same mock definitions in a single test suite.
  • Define reusable mock expectations with regex patterns and JSON Schema validation for request bodies.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

pook intercepts and mocks HTTP traffic for testing, supporting popular Python HTTP clients with a fluent API, regex matching, JSON/XML support, and pluggable mock engines.

Yes. pook is actively maintained, has no known vulnerabilities, low install friction, and a permissive MIT license. It solves a common testing need (HTTP mocking) with a clean API that works across multiple HTTP clients. Install it if you need to mock HTTP traffic in tests and want flexibility in matching and response definition.

Install

pook on PyPI

pip

pip install pook

uv

uv add pook

poetry

poetry add pook

Installing pook

Before you install

Low friction: pure Python wheel with only 3 runtime dependencies (furl, jsonschema, xmltodict). Actively maintained with last commit 2026-03-11.

License in practice

MIT license (permissive) means you can use pook freely in commercial and private projects with minimal restrictions; attribution is appreciated but not legally required.

Quickstart

pip install pook

import pook

@pook.on
def test_api():
    mock = pook.get('http://example.com/api', reply=200, response_json={'status': 'ok'})
    assert mock.calls == 0

Requires Python 3.10 or later (CPython or PyPy); only recent versions of supported HTTP clients are tested.

Verify before relying

  • Whether network delay simulation (mentioned for aiohttp) is fully functional or experimental.
  • Specific version constraints for runtime dependencies (furl, jsonschema, xmltodict) beyond pip resolution.
  • Real-world compatibility with HTTP client versions newer than those tested.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — furl, jsonschema, xmltodict
Maintenance actively maintained — 161 days since the last release
Last repo commit
First released
Downloads 270,323/month — #8,237 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pook-2.1.6-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python Modules

Tags

http mocking library pythonmock http requests testinghttp traffic interceptiontest http client responseshttp response stubbingmock decorator testinghttp mock expectations
http-mockingtest-doublesrequest-interception

More Software Development packages