Last active
April 28, 2020 10:51
-
-
Save ryanc414/17b60d9730962304abf694c48fcc8bdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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