@@ -744,6 +744,25 @@ suite('InlineScriptEnvManager', () => {
744744 assert . strictEqual ( createWithProgressStub . callCount , 1 ) ;
745745 } ) ;
746746
747+ test ( 'uses strict PEP 440 matching for a directly resolved final release' , async ( ) => {
748+ const uvExecutable = path . join ( tempRoot , 'uv-python' , isWindows ( ) ? 'python.exe' : 'python' ) ;
749+ await fs . outputFile ( uvExecutable , '' ) ;
750+ const uvBase = makeEnvironment ( 'ms-python.python:system' , '3.15.0' , uvExecutable ) ;
751+ readMetadataStub . resolves ( { ...VALID_METADATA , requiresPython : '!=3.15.0rc2' } ) ;
752+ apiGetEnvironmentsStub . resolves ( [ ] ) ;
753+ getAvailablePythonVersionsStub . resolves ( [ makeUvPythonVersion ( '3.15.0' ) ] ) ;
754+ promptInstallPythonViaUvStub . resolves ( { kind : 'installed' , pythonPath : uvExecutable } ) ;
755+ resolveSystemPythonStub . resolves ( uvBase ) ;
756+
757+ assert . ok ( await manager . create ( scriptUri ( ) ) ) ;
758+
759+ sinon . assert . calledOnceWithExactly ( promptInstallPythonViaUvStub , 'inlineScript' , manager . log , {
760+ requiresPython : '!=3.15.0rc2' ,
761+ version : '3.15.0' ,
762+ } ) ;
763+ assert . strictEqual ( createWithProgressStub . firstCall . args [ 4 ] , uvBase ) ;
764+ } ) ;
765+
747766 test ( 'selects an available uv release that satisfies exclusion clauses' , async ( ) => {
748767 const uvExecutable = path . join ( tempRoot , 'uv-python' , isWindows ( ) ? 'python.exe' : 'python' ) ;
749768 await fs . outputFile ( uvExecutable , '' ) ;
@@ -834,6 +853,46 @@ suite('InlineScriptEnvManager', () => {
834853 requiresPython : '>=3.11,<3.12' ,
835854 version : '3.11.14' ,
836855 } ) ;
856+ sinon . assert . calledOnceWithExactly ( getAvailablePythonVersionsStub ) ;
857+ } ) ;
858+
859+ test ( 'resolves a short exact requirement to an advertised concrete release' , async ( ) => {
860+ const uvExecutable = path . join ( tempRoot , 'uv-python' , isWindows ( ) ? 'python.exe' : 'python' ) ;
861+ await fs . outputFile ( uvExecutable , '' ) ;
862+ const uvBase = makeEnvironment ( 'ms-python.python:system' , '3.13.0' , uvExecutable ) ;
863+ readMetadataStub . resolves ( { ...VALID_METADATA , requiresPython : '==3.13' } ) ;
864+ apiGetEnvironmentsStub . onFirstCall ( ) . resolves ( [ baseEnvironment ] ) ;
865+ apiGetEnvironmentsStub . onSecondCall ( ) . resolves ( [ baseEnvironment ] ) ;
866+ apiGetEnvironmentsStub . onThirdCall ( ) . resolves ( [ uvBase ] ) ;
867+ const defaultCatalog = [ makeUvPythonVersion ( '3.13.2' ) ] ;
868+ const completeCatalog = [ ...defaultCatalog , makeUvPythonVersion ( '3.13.0' ) ] ;
869+ getAvailablePythonVersionsStub . callsFake ( async ( options ?: { allVersions ?: boolean } ) =>
870+ options ?. allVersions ? completeCatalog : defaultCatalog ,
871+ ) ;
872+ promptInstallPythonViaUvStub . resolves ( { kind : 'installed' , pythonPath : uvExecutable } ) ;
873+
874+ assert . ok ( await manager . create ( scriptUri ( ) ) ) ;
875+
876+ sinon . assert . calledOnceWithExactly ( ensureUvForVersionLookupStub , '==3.13' , manager . log ) ;
877+ sinon . assert . calledOnceWithExactly ( getAvailablePythonVersionsStub , { allVersions : true } ) ;
878+ sinon . assert . calledOnceWithExactly ( promptInstallPythonViaUvStub , 'inlineScript' , manager . log , {
879+ requiresPython : '==3.13' ,
880+ version : '3.13.0' ,
881+ } ) ;
882+ } ) ;
883+
884+ test ( 'does not install a short exact requirement without an exact catalog candidate' , async ( ) => {
885+ readMetadataStub . resolves ( { ...VALID_METADATA , requiresPython : '==3.13' } ) ;
886+ apiGetEnvironmentsStub . resolves ( [ baseEnvironment ] ) ;
887+ getAvailablePythonVersionsStub . resolves ( [ makeUvPythonVersion ( '3.13.2' ) ] ) ;
888+
889+ assert . strictEqual ( await manager . create ( scriptUri ( ) ) , undefined ) ;
890+
891+ sinon . assert . calledOnceWithExactly ( ensureUvForVersionLookupStub , '==3.13' , manager . log ) ;
892+ sinon . assert . calledOnceWithExactly ( getAvailablePythonVersionsStub , { allVersions : true } ) ;
893+ assert . strictEqual ( promptInstallPythonViaUvStub . callCount , 0 ) ;
894+ assert . strictEqual ( apiRefreshEnvironmentsStub . callCount , 0 ) ;
895+ assert . strictEqual ( createWithProgressStub . callCount , 0 ) ;
837896 } ) ;
838897
839898 test ( 'uses an exact requirement without needing an existing uv catalog' , async ( ) => {
0 commit comments