Skip to content

Instantly share code, notes, and snippets.

@wshayes
Created June 20, 2019 13:09
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 wshayes/5fbe1368c7aafad444915e92989d2dc1 to your computer and use it in GitHub Desktop.
Save wshayes/5fbe1368c7aafad444915e92989d2dc1 to your computer and use it in GitHub Desktop.
[Testclient example for FastAPI] #fastapi
# From: euri10 @euri10 Jun 19 10:42
@pytest.mark.parametrize("user, expected_status_code", data)
def test_update_user(client, another_user, user, expected_status_code):
url = app.url_path_for("enable")
response = client.patch(url, params={"email": another_user.email})
assert response.status_code == 401
# client is a small fixture but ymmv:
@pytest.fixture()
def client():
with TestClient(app) as client:
yield client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment