Browse Source

test: address multipart version PR review feedback

Make the 0.0.100 regression test fail on master by removing multipart
fallback, and move _version_str_to_tuple tests to test_dependencies_utils.
pull/15226/head
esubaalew 1 week ago
parent
commit
2c010f68e8
  1. 9
      tests/test_dependencies_utils.py
  2. 9
      tests/test_multipart_installation.py

9
tests/test_dependencies_utils.py

@ -1,4 +1,11 @@
from fastapi.dependencies.utils import get_typed_annotation
from fastapi.dependencies.utils import _version_str_to_tuple, get_typed_annotation
def test_version_str_to_tuple():
assert _version_str_to_tuple("0.0.12") == (0, 0, 12)
assert _version_str_to_tuple("0.0.100") == (0, 0, 100)
assert _version_str_to_tuple("1.2.3a1") == (1, 2, 3)
assert _version_str_to_tuple("") == ()
def test_get_typed_annotation():

9
tests/test_multipart_installation.py

@ -3,7 +3,6 @@ import warnings
import pytest
from fastapi import FastAPI, File, Form, UploadFile
from fastapi.dependencies.utils import (
_version_str_to_tuple,
multipart_incorrect_install_error,
multipart_not_installed_error,
)
@ -154,15 +153,9 @@ def test_new_multipart_version_without_multipart_alias(monkeypatch):
monkeypatch.setattr("python_multipart.__version__", "0.0.100")
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
monkeypatch.delattr("multipart.__version__", raising=False)
app = FastAPI()
@app.post("/")
async def root(username: str = Form()):
return username # pragma: nocover
def test_version_str_to_tuple():
assert _version_str_to_tuple("0.0.12") == (0, 0, 12)
assert _version_str_to_tuple("0.0.100") == (0, 0, 100)
assert _version_str_to_tuple("1.2.3a1") == (1, 2, 3)
assert _version_str_to_tuple("") == ()

Loading…
Cancel
Save