@@ -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 )
761805def test_client_install_run (session : Session ):
762806 with alter_session (session , dependency_group = "dev" ):
0 commit comments