committed by
GitHub
7 changed files with 1207 additions and 104 deletions
File diff suppressed because it is too large
@ -1,17 +1,20 @@ |
|||||
import importlib |
import importlib |
||||
|
|
||||
import pytest |
import pytest |
||||
from fastapi.exceptions import FastAPIError |
|
||||
|
|
||||
from ...utils import needs_py310 |
from ...utils import needs_py310 |
||||
|
|
||||
|
|
||||
|
# Previously, unions including `Response` in the return annotation were |
||||
|
# considered invalid and raised FastAPIError at import time. |
||||
|
# They are now supported as part of the enhanced return annotation handling. |
||||
|
# Importing the module should not raise FastAPIError anymore. |
||||
@pytest.mark.parametrize( |
@pytest.mark.parametrize( |
||||
"module_name", |
"module_name", |
||||
[ |
[ |
||||
pytest.param("tutorial003_04_py310", marks=needs_py310), |
pytest.param("tutorial003_04_py310", marks=needs_py310), |
||||
], |
], |
||||
) |
) |
||||
def test_invalid_response_model(module_name: str) -> None: |
def test_response_union_with_response_is_valid(module_name: str) -> None: |
||||
with pytest.raises(FastAPIError): |
module = importlib.import_module(f"docs_src.response_model.{module_name}") |
||||
importlib.import_module(f"docs_src.response_model.{module_name}") |
assert module is not None |
||||
|
|||||
Loading…
Reference in new issue