Skip to main content

Python 3 library to mock a http server using Flask

Project description

http-server-mock on PyPI (Python Package Index) Travis CI tests (Linux) Test coverage on Coveralls

http-server-mock is a HTTP Server Mock using Flask. You can use it to test possible integrations with your application.

http-server-mock is available on PyPI. To install it just run:

pip install http-server-mock

Using http-server-mock is similar to implement any Flask application.

from http_server_mock import HttpServerMock
import requests
app = HttpServerMock(__name__)

@app.route("/", methods=["GET"])
def index():
    return "Hello world"

with"localhost", 5000):
    r = requests.get("http://localhost:5000/")
    # r.status_code == 200
    # r.text == "Hello world"

HttpServerMock will use a random route to know if the http server is running, if you want to set a specific route to do it just set the parameter is_alive_route:

from http_server_mock import HttpServerMock
app = HttpServerMock(__name__, is_alive_route="/is-alive")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
http_server_mock-1.2.tar.gz (15.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page