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

13 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1import importlib 1abcdefg

2 

3import pytest 1abcdefg

4from fastapi.testclient import TestClient 1abcdefg

5 

6from ...utils import needs_py39 1abcdefg

7 

8 

9@pytest.fixture( 1abcdefg

10 name="client", 

11 params=[ 

12 "tutorial008e", 

13 "tutorial008e_an", 

14 pytest.param("tutorial008e_an_py39", marks=needs_py39), 

15 ], 

16) 

17def get_client(request: pytest.FixtureRequest): 1abcdefg

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

19 

20 client = TestClient(mod.app) 1abcdefg

21 return client 1abcdefg

22 

23 

24def test_get_users_me(client: TestClient): 1abcdefg

25 response = client.get("/users/me") 1hijklmn

26 assert response.status_code == 200, response.text 1hijklmn

27 assert response.json() == "Rick" 1hijklmn