pytest-httpbin 2.1.0


pip install pytest-httpbin

  Latest version

Released: Sep 18, 2024

Project Links

Meta
Author: Kevin McCarthy
Requires Python: >=3.8

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

Topic
  • Software Development :: Testing
  • Software Development :: Libraries

License
  • OSI Approved :: MIT License

Programming Language
  • Python :: 3
  • Python :: 3 :: Only
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11

httpbin is an amazing web service for testing HTTP libraries. It has several great endpoints that can test pretty much everything you need in a HTTP library. The only problem is: maybe you don’t want to wait for your tests to travel across the Internet and back to make assertions against a remote web service.

Enter pytest-httpbin. Pytest-httpbin creates a pytest “fixture” that is dependency-injected into your tests. It automatically starts up a HTTP server in a separate thread running httpbin and provides your test with the URL in the fixture. Check out this example:

def test_that_my_library_works_kinda_ok(httpbin):
    assert requests.get(httpbin.url + '/get/').status_code == 200

This replaces a test that might have looked like this before:

def test_that_my_library_works_kinda_ok():
    assert requests.get('http://httpbin.org/get').status_code == 200

pytest-httpbin also supports https and includes its own CA cert you can use. Check out the full documentation on the github page.

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
httpbin