Install & Compatibility
Where this runs
tested against v2.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
build_error
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 5.2s · import 0.000s · 58MB
57MB installed
● package 57MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
httpbin
✓ def test_example(httpbin):
# httpbin fixture is automatically discovered by pytest and passed as argument
response = requests.get(httpbin.url + '/get')
✗ from pytest_httpbin import httpbin
pytest fixtures are automatically discovered and injected into test functions; explicit import is unnecessary and will lead to `ModuleNotFoundError` or incorrect usage.
httpbin_secure
✓ def test_secure(httpbin_secure, httpbin_ca_bundle):
# httpbin_secure fixture for HTTPS tests
response = requests.get(httpbin_secure.url + '/get', verify=httpbin_ca_bundle)
✗ from pytest_httpbin import httpbin_secure
Same as 'httpbin', fixtures are discovered by pytest, not imported directly.
httpbin_ca_bundle
✓ def test_ca_bundle(httpbin_secure, httpbin_ca_bundle):
# httpbin_ca_bundle provides path to CA certificate for HTTPS verification
response = requests.get(httpbin_secure.url + '/get', verify=httpbin_ca_bundle)
✗ from pytest_httpbin import httpbin_ca_bundle
Same as 'httpbin', fixtures are discovered by pytest, not imported directly.
Create a Python file (e.g., `test_my_app.py`) and define test functions that accept `pytest-httpbin` fixtures like `httpbin`, `httpbin_secure`, and `httpbin_ca_bundle`. Pytest will automatically discover and inject these fixtures. Run the tests using the `pytest` command in your terminal. Ensure `requests` is also installed (`pip install requests`) to make HTTP calls.
import pytest
import requests
def test_get_request(httpbin):
"""Test a simple GET request against the local httpbin instance."""
print(f"Testing against httpbin at: {httpbin.url}")
response = requests.get(httpbin.url + '/get')
response.raise_for_status()
data = response.json()
assert data['headers']['Host'] == httpbin.host
def test_post_request(httpbin):
"""Test a POST request."""
payload = {'key': 'value'}
response = requests.post(httpbin.url + '/post', json=payload)
response.raise_for_status()
data = response.json()
assert data['json'] == payload
def test_secure_request(httpbin_secure, httpbin_ca_bundle):
"""Test an HTTPS request with CA bundle verification."""
print(f"Testing against secure httpbin at: {httpbin_secure.url}")
# Note: requests must be explicitly told to verify with the provided CA bundle
response = requests.get(httpbin_secure.url + '/get', verify=httpbin_ca_bundle)
response.raise_for_status()
data = response.json()
assert data['headers']['Host'] == httpbin_secure.host
# To run this, save as `test_httpbin_example.py` and run `pytest` in your terminal.
Upgrade
Version history
2.1.0latest on PyPI · released Sep 18, 2024
Audit
Dependencies
pytestrequiredpytest-httpbin is a plugin for pytest, requiring it to run tests.