Coverage for tests / test_tutorial / test_dependencies / test_tutorial008e.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1import importlib 1abdc

2 

3import pytest 1abdc

4from fastapi.testclient import TestClient 1abdc

5 

6 

7@pytest.fixture( 1abdc

8 name="client", 

9 params=[ 

10 pytest.param("tutorial008e_py310"), 

11 pytest.param("tutorial008e_an_py310"), 

12 ], 

13) 

14def get_client(request: pytest.FixtureRequest): 1abdc

15 mod = importlib.import_module(f"docs_src.dependencies.{request.param}") 1abc

16 

17 client = TestClient(mod.app) 1abc

18 return client 1abc

19 

20 

21def test_get_users_me(client: TestClient): 1abdc

22 response = client.get("/users/me") 1efg

23 assert response.status_code == 200, response.text 1efg

24 assert response.json() == "Rick" 1efg