Coverage for tests / test_dependency_pep695.py: 100%

16 statements  

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

1from typing import Annotated 1efgh

2 

3from fastapi import Depends, FastAPI 1efgh

4from fastapi.testclient import TestClient 1efgh

5from typing_extensions import TypeAliasType 1efgh

6 

7 

8async def some_value() -> int: 1efgh

9 return 123 1abcd

10 

11 

12DependedValue = TypeAliasType( 1efgh

13 "DependedValue", Annotated[int, Depends(some_value)], type_params=() 

14) 

15 

16 

17def test_pep695_type_dependencies(): 1efgh

18 app = FastAPI() 1abcd

19 

20 @app.get("/") 1abcd

21 async def get_with_dep(value: DependedValue) -> str: # noqa 1abcd

22 return f"value: {value}" 1abcd

23 

24 client = TestClient(app) 1abcd

25 response = client.get("/") 1abcd

26 assert response.status_code == 200 1abcd

27 assert response.text == '"value: 123"' 1abcd