Skip to content

Commit a3d2c6a

Browse files
author
Super User
committed
#94; compat tests passed locally
1 parent 3f672fb commit a3d2c6a

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

.github/workflows/tests.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ jobs:
100100
run: |
101101
uv run python -m pytest tests/ -vv -s
102102
103+
104+
- name: Run fastapi compatibility tests
105+
env:
106+
PYTHONWARNINGS: ignore
107+
if: steps.check_test_files.outputs.files_exists == 'true'
108+
env:
109+
PYTHONWARNINGS: ignore
110+
run: |
111+
uv run nox -s test-compat-fastapi
112+
103113
#----------------------------------------------
104114
# make sure docs build
105115
#----------------------------------------------

noxfile.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ def test_compat_fastapi(session: AlteredSession, fastapi_version: str):
392392
PyPI's latest release, selecting the highest patch per minor.
393393
"""
394394
session.log(f"Testing compatibility with FastAPI versions: {FASTAPI_MINOR_MATRIX}")
395-
with alter_session(session, dependency_group=None) as session:
396-
build(session)
397395
# Pin FastAPI (and extras) to the target minor's highest patch before running tests.
398396
# Install dev dependencies excluding FastAPI to avoid overriding the pinned version.
399397
pyproject = load_toml(MANIFEST_FILENAME)
@@ -403,6 +401,16 @@ def test_compat_fastapi(session: AlteredSession, fastapi_version: str):
403401
session.install(*filtered_dev_deps)
404402
# Pin FastAPI (and extras) to the target minor's highest patch before running tests.
405403
session.install(f"fastapi[standard]=={fastapi_version}")
404+
with alter_session(session, dependency_group=None) as session:
405+
install_latest(session)
406+
session.run(
407+
*(
408+
"python",
409+
"-c",
410+
f'from fastapi import __version__; assert __version__ == "{fastapi_version}", __version__',
411+
)
412+
)
413+
406414
# Run pytest using the Nox-managed virtualenv (avoid external interpreter).
407415
session.run("pytest")
408416

@@ -757,6 +765,42 @@ def ci(session: Session):
757765
test(session)
758766

759767

768+
@session(reuse_venv=False)
769+
def install_latest(session: Session):
770+
import glob
771+
import re
772+
773+
from packaging import version
774+
775+
# Get all tarball files
776+
tarball_files = glob.glob(f"{DIST_DIR}/{PROJECT_NAME_NORMALIZED}-*.tar.gz")
777+
778+
if not tarball_files:
779+
session.error("No tarball files found in dist/ directory")
780+
781+
# Extract version numbers using regex
782+
version_pattern = re.compile(
783+
rf"{PROJECT_NAME_NORMALIZED}-([0-9]+\.[0-9]+\.[0-9]+(?:\.[0-9]+)?(?:(?:a|b|rc)[0-9]+)?(?:\.post[0-9]+)?(?:\.dev[0-9]+)?).tar.gz"
784+
)
785+
786+
# Create a list of (file_path, version) tuples
787+
versioned_files = []
788+
for file_path in tarball_files:
789+
match = version_pattern.search(file_path)
790+
if match:
791+
ver_str = match.group(1)
792+
versioned_files.append((file_path, version.parse(ver_str)))
793+
794+
if not versioned_files:
795+
session.error("Could not extract version information from tarball files")
796+
797+
# Sort by version (highest first) and get the path
798+
latest_tarball = sorted(versioned_files, key=lambda x: x[1], reverse=True)[0][0]
799+
session.log(f"Installing latest version: {latest_tarball}")
800+
session.run("uv", "run", "pip", "uninstall", f"{PROJECT_NAME}", "-y")
801+
session.install(latest_tarball)
802+
803+
760804
@session(reuse_venv=False)
761805
def test_client_install_run(session: Session):
762806
with alter_session(session, dependency_group="dev"):

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ reportMissingImports = "none"
116116
[dependency-groups]
117117
dev = [
118118
"bcrypt==4.3.0",
119+
"email-validator>=2.3.0",
119120
"fastapi>=0.115.2",
120121
"httpx>=0.24.0",
121122
"isort>=6.0.1",

0 commit comments

Comments
 (0)