Sync fastapi docs from b5ca1324 on 2025-12-07
Issue Manager / issue-manager (push) Has been cancelled
Build Docs / changes (push) Has been cancelled
Build Docs / langs (push) Has been cancelled
Build Docs / build-docs (push) Has been cancelled
Build Docs / docs-all-green (push) Has been cancelled
Conflict detector / main (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi) (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi-slim) (push) Has been cancelled
Test Redistribute / test-redistribute-alls-green (push) Has been cancelled
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.13) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.13) (push) Has been cancelled
Test / test (pydantic-v2, 3.14) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
FastAPI People Contributors / job (push) Has been cancelled
FastAPI People Sponsors / job (push) Has been cancelled
Update Topic Repos / topic-repos (push) Has been cancelled
FastAPI People / job (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
Issue Manager / issue-manager (push) Has been cancelled
Build Docs / changes (push) Has been cancelled
Build Docs / langs (push) Has been cancelled
Build Docs / build-docs (push) Has been cancelled
Build Docs / docs-all-green (push) Has been cancelled
Conflict detector / main (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi) (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi-slim) (push) Has been cancelled
Test Redistribute / test-redistribute-alls-green (push) Has been cancelled
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.13) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.13) (push) Has been cancelled
Test / test (pydantic-v2, 3.14) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
FastAPI People Contributors / job (push) Has been cancelled
FastAPI People Sponsors / job (push) Has been cancelled
Update Topic Repos / topic-repos (push) Has been cancelled
FastAPI People / job (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI, File, Form, UploadFile
|
||||
from fastapi.dependencies.utils import (
|
||||
multipart_incorrect_install_error,
|
||||
multipart_not_installed_error,
|
||||
)
|
||||
|
||||
|
||||
def test_incorrect_multipart_installed_form(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form()):
|
||||
return username # pragma: nocover
|
||||
|
||||
|
||||
def test_incorrect_multipart_installed_file_upload(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(f: UploadFile = File()):
|
||||
return f # pragma: nocover
|
||||
|
||||
|
||||
def test_incorrect_multipart_installed_file_bytes(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(f: bytes = File()):
|
||||
return f # pragma: nocover
|
||||
|
||||
|
||||
def test_incorrect_multipart_installed_multi_form(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form(), password: str = Form()):
|
||||
return username # pragma: nocover
|
||||
|
||||
|
||||
def test_incorrect_multipart_installed_form_file(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form(), f: UploadFile = File()):
|
||||
return username # pragma: nocover
|
||||
|
||||
|
||||
def test_no_multipart_installed(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.__version__", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_not_installed_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form()):
|
||||
return username # pragma: nocover
|
||||
|
||||
|
||||
def test_no_multipart_installed_file(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.__version__", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_not_installed_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(f: UploadFile = File()):
|
||||
return f # pragma: nocover
|
||||
|
||||
|
||||
def test_no_multipart_installed_file_bytes(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.__version__", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_not_installed_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(f: bytes = File()):
|
||||
return f # pragma: nocover
|
||||
|
||||
|
||||
def test_no_multipart_installed_multi_form(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.__version__", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_not_installed_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form(), password: str = Form()):
|
||||
return username # pragma: nocover
|
||||
|
||||
|
||||
def test_no_multipart_installed_form_file(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
monkeypatch.delattr("multipart.__version__", raising=False)
|
||||
with pytest.raises(RuntimeError, match=multipart_not_installed_error):
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form(), f: UploadFile = File()):
|
||||
return username # pragma: nocover
|
||||
|
||||
|
||||
def test_old_multipart_installed(monkeypatch):
|
||||
monkeypatch.setattr("python_multipart.__version__", "0.0.12")
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(username: str = Form()):
|
||||
return username # pragma: nocover
|
||||
Reference in New Issue
Block a user