Skip to content

Instantly share code, notes, and snippets.

@ryanc414
Created April 19, 2020 20:20
Show Gist options
  • Save ryanc414/6cff024f0c873c222dc7fba5f4220ce9 to your computer and use it in GitHub Desktop.
Save ryanc414/6cff024f0c873c222dc7fba5f4220ce9 to your computer and use it in GitHub Desktop.
@pytest.fixture(scope="module")
def app():
app = App()
print("Starting app")
app.start()
yield app
print("Stopping app")
app.stop()
def test_app_get(app):
"""Test making an HTTP GET request to my app."""
rsp = requests.get(f"{app.listen_addr}/hello")
assert rsp.status_code == 200
assert rsp.text == 'Hello, "/hello"'
def test_app_put(app):
"""Test making an HTTP PUT request to my app."""
rsp = requests.put(f"{app.listen_addr}/hello")
assert rsp.status_code == 200
assert rsp.text == 'Hello, "/hello"'
def test_app_post(app):
"""Test making an HTTP POST request to my app."""
rsp = requests.post(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