Skip to content

sysfce2/python-pytest-httpserver

Repository files navigation

pytest_httpserver

HTTP server for pytest

Nutshell

This library is designed to help to test http clients without contacting the real http server. In other words, it is a fake http server which is accessible via localhost can be started with the pre-defined expected http requests and their responses.

Example

def test_my_client(server): # server is a pytest fixture which starts the server
    # set up the server to serve /foobar with the json
    server.expect_request("/foobar").respond_with_json({"foo": "bar"})
    # check sthat it is served
    assert requests.get(server.url_for("/foobar")).json() == {'foo': 'bar'}

About

Http server for pytest to test http clients (Required by python-pooch) | (PKGBUILD: https://archlinux.org/packages/extra/any/python-pytest-httpserver)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 98.1%
  • Makefile 1.2%
  • Nix 0.7%