| 1 |
import importlib |
| 2 |
|
| 3 |
import pytest |
| 4 |
from fastapi.testclient import TestClient |
| 5 |
|
| 6 |
|
| 7 |
@pytest.fixture( |
| 8 |
name="client", |
| 9 |
params=[ |
| 10 |
pytest.param("tutorial008e_py310"), |
| 11 |
pytest.param("tutorial008e_an_py310"), |
| 12 |
], |
| 13 |
) |
| 14 |
def get_client(request: pytest.FixtureRequest): |
| 15 |
mod = importlib.import_module(f"docs_src.dependencies.{request.param}") |
| 16 |
|
| 17 |
client = TestClient(mod.app) |
| 18 |
return client |
| 19 |
|
| 20 |
|
| 21 |
def test_get_users_me(client: TestClient): |
| 22 |
response = client.get("/users/me") |
| 23 |
assert response.status_code == 200, response.text |
| 24 |
assert response.json() == "Rick" |