{"id":10142,"library":"pytest-httpbin","title":"pytest-httpbin","description":"pytest-httpbin is a pytest plugin that provides fixtures to easily test your HTTP library against a local, self-hosted copy of httpbin.org. It's currently at version 2.1.0 and has an infrequent, release-as-needed cadence, primarily for compatibility updates with newer Python or pytest versions.","status":"active","version":"2.1.0","language":"python","source_language":"en","source_url":"https://github.com/kevin1024/pytest-httpbin","tags":["pytest","http","testing","fixtures","plugin"],"install":[{"cmd":"pip install pytest-httpbin requests","lang":"bash","label":"Install stable version (includes requests for quickstart)"}],"dependencies":[{"reason":"pytest-httpbin is a plugin for pytest, requiring it to run tests.","package":"pytest","optional":false}],"imports":[{"note":"pytest fixtures are automatically discovered and injected into test functions; explicit import is unnecessary and will lead to `ModuleNotFoundError` or incorrect usage.","wrong":"from pytest_httpbin import httpbin","symbol":"httpbin","correct":"def test_example(httpbin):\n    # httpbin fixture is automatically discovered by pytest and passed as argument\n    response = requests.get(httpbin.url + '/get')"},{"note":"Same as 'httpbin', fixtures are discovered by pytest, not imported directly.","wrong":"from pytest_httpbin import httpbin_secure","symbol":"httpbin_secure","correct":"def test_secure(httpbin_secure, httpbin_ca_bundle):\n    # httpbin_secure fixture for HTTPS tests\n    response = requests.get(httpbin_secure.url + '/get', verify=httpbin_ca_bundle)"},{"note":"Same as 'httpbin', fixtures are discovered by pytest, not imported directly.","wrong":"from pytest_httpbin import httpbin_ca_bundle","symbol":"httpbin_ca_bundle","correct":"def test_ca_bundle(httpbin_secure, httpbin_ca_bundle):\n    # httpbin_ca_bundle provides path to CA certificate for HTTPS verification\n    response = requests.get(httpbin_secure.url + '/get', verify=httpbin_ca_bundle)"}],"quickstart":{"code":"import pytest\nimport requests\n\ndef test_get_request(httpbin):\n    \"\"\"Test a simple GET request against the local httpbin instance.\"\"\"\n    print(f\"Testing against httpbin at: {httpbin.url}\")\n    response = requests.get(httpbin.url + '/get')\n    response.raise_for_status()\n    data = response.json()\n    assert data['headers']['Host'] == httpbin.host\n\ndef test_post_request(httpbin):\n    \"\"\"Test a POST request.\"\"\"\n    payload = {'key': 'value'}\n    response = requests.post(httpbin.url + '/post', json=payload)\n    response.raise_for_status()\n    data = response.json()\n    assert data['json'] == payload\n\ndef test_secure_request(httpbin_secure, httpbin_ca_bundle):\n    \"\"\"Test an HTTPS request with CA bundle verification.\"\"\"\n    print(f\"Testing against secure httpbin at: {httpbin_secure.url}\")\n    # Note: requests must be explicitly told to verify with the provided CA bundle\n    response = requests.get(httpbin_secure.url + '/get', verify=httpbin_ca_bundle)\n    response.raise_for_status()\n    data = response.json()\n    assert data['headers']['Host'] == httpbin_secure.host\n\n# To run this, save as `test_httpbin_example.py` and run `pytest` in your terminal.","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your project uses Python 3.7 or newer before upgrading to `pytest-httpbin` 2.x. If you must use older Python, pin `pytest-httpbin` to `<2.0.0`.","message":"Version 2.0.0 dropped support for older Python versions (2.6, 2.7, 3.4, 3.5, 3.6). It introduced support for Python 3.7+ (up to 3.12).","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Review tests that explicitly manipulate or inspect the SSL certificate provided by `httpbin_secure`. Most users verifying with `httpbin_ca_bundle` should be unaffected.","message":"Version 1.0.0 updated the self-signed certificate provided by `httpbin_secure` to include the IP address in the Subject Alternative Name (SAN). This could be a breaking change for tests that explicitly depended on the certificate *not* having the IP address in the SAN.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always use `verify=httpbin_ca_bundle` (e.g., `requests.get(httpbin_secure.url, verify=httpbin_ca_bundle)`) when making requests to `httpbin_secure` in your tests.","message":"When using the `httpbin_secure` fixture for HTTPS tests, client-side SSL verification will fail unless you explicitly pass the `httpbin_ca_bundle` fixture's path to your HTTP client's `verify` parameter.","severity":"gotcha","affected_versions":"all"},{"fix":"To specify a port, define the environment variable before running pytest, e.g., `HTTPBIN_HTTP_PORT=8000 pytest`.","message":"The httpbin server can be configured to run on a fixed port by setting `HTTPBIN_HTTP_PORT` or `HTTPBIN_HTTPS_PORT` environment variables before running pytest. If not set, a random available port is chosen.","severity":"gotcha","affected_versions":">=0.3.0"}],"env_vars":null,"search_vec":"'2.1.0':34 'cadenc':43 'compat':46 'copi':26 'current':31 'easili':15 'fixtur':13,57 'host':25 'http':18,55 'httpbin':3,6 'httpbin.org':28 'infrequ':38 'librari':19 'local':22 'need':42 'newer':49 'plugin':10,58 'primarili':44 'provid':12 'pytest':2,5,9,52,54 'pytest-httpbin':1,4 'python':50 'releas':40 'release-as-need':39 'self':24 'self-host':23 'test':16,56 'updat':47 'version':33,53","created_at":"2026-04-17T01:22:35.460387+00:00","updated_at":"2026-04-17T01:22:35.460387+00:00","problems":{"verify_error":"no import statement found"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.1.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://pypi.org/project/pytest-httpbin/","github":"https://github.com/kevin1024/pytest-httpbin","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-httpbin/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"skip","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}