Skip to content

Instantly share code, notes, and snippets.

@ryanc414
Last active April 28, 2020 10:51
Show Gist options
  • Save ryanc414/17b60d9730962304abf694c48fcc8bdf to your computer and use it in GitHub Desktop.
Save ryanc414/17b60d9730962304abf694c48fcc8bdf to your computer and use it in GitHub Desktop.
# First test with the default port, then test using a fixed port
# number.
@pytest.fixture(scope="module", params=[None, 9999])
def app(request):
app = App(port=request.param)
print("Starting app")
app.start()
yield app
print("Stopping app")
app.stop()
@pytest.mark.parametrize("method", ["GET", "PUT", "POST"])
def test_app(app, method):
"""Test making an HTTP request to my app."""
rsp = requests.request(method, f"{app.listen_addr}/hello")
assert rsp.status_code == 200
assert rsp.text == 'Hello, "/hello"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment