mirror of https://github.com/tiangolo/fastapi.git
Cover dep() stubs by calling them in tests
Replace pragma: no cover with actual calls to the dep() helper functions so their bodies are exercised during the test run. Made-with: Cursor
This commit is contained in:
parent
fff2b10e04
commit
bba0d61092
|
|
@ -73,8 +73,9 @@ def test_try_resolve_strict_success():
|
|||
"""Fully resolvable annotation returns immediately via strict eval."""
|
||||
|
||||
def dep() -> str:
|
||||
return "ok" # pragma: no cover
|
||||
return "ok"
|
||||
|
||||
assert dep() == "ok"
|
||||
ns = {"Annotated": Annotated, "str": str, "Depends": Depends, "dep": dep}
|
||||
result = _try_resolve_annotated("Annotated[str, Depends(dep)]", ns)
|
||||
assert result is not None
|
||||
|
|
@ -90,8 +91,9 @@ def test_try_resolve_lenient_with_depends():
|
|||
"""Unresolvable type + Depends → Annotated[Any, Depends(...)]."""
|
||||
|
||||
def dep() -> str:
|
||||
return "ok" # pragma: no cover
|
||||
return "ok"
|
||||
|
||||
assert dep() == "ok"
|
||||
ns = {"Annotated": Annotated, "Depends": Depends, "dep": dep}
|
||||
result = _try_resolve_annotated("Annotated[MissingClass, Depends(dep)]", ns)
|
||||
assert result is not None
|
||||
|
|
@ -146,8 +148,9 @@ def test_get_typed_annotation_annotated_with_result():
|
|||
"""Annotated string that resolves via _try_resolve_annotated."""
|
||||
|
||||
def dep() -> str:
|
||||
return "ok" # pragma: no cover
|
||||
return "ok"
|
||||
|
||||
assert dep() == "ok"
|
||||
ns = {"Annotated": Annotated, "str": str, "Depends": Depends, "dep": dep}
|
||||
result = get_typed_annotation("Annotated[str, Depends(dep)]", ns)
|
||||
assert get_origin(result) is Annotated
|
||||
|
|
|
|||
Loading…
Reference in New Issue