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

12 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1import importlib 1abcd

2 

3import pytest 1abcd

4from fastapi.testclient import TestClient 1abcd

5 

6 

7@pytest.fixture( 1abcd

8 name="client", 

9 params=[ 

10 pytest.param("tutorial008e_py310"), 

11 pytest.param("tutorial008e_an_py310"), 

12 ], 

13) 

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

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

16 

17 client = TestClient(mod.app) 1efghijkl

18 return client 1efghijkl

19 

20 

21def test_get_users_me(client: TestClient): 1abcd

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

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

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