Skip to content

Instantly share code, notes, and snippets.

@ryanc414
Last active April 28, 2020 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanc414/804e76e9f38c5183b80d1e4ad97ff357 to your computer and use it in GitHub Desktop.
Save ryanc414/804e76e9f38c5183b80d1e4ad97ff357 to your computer and use it in GitHub Desktop.
class AppClient:
def __init__(self, app_addr):
self._app_addr = app_addr
def request(self, method, path):
return requests.request(method, f"{self._app_addr}{path}")
@pytest.fixture(scope="function")
def app_client(app):
return AppClient(app.listen_addr)
@pytest.mark.parametrize("method", ["GET", "PUT", "POST"])
def test_app(app_client, method):
"""Test making an HTTP request to my app."""
rsp = app_client.request(method, "/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