@@ -2,6 +2,7 @@ use std::path::PathBuf;
22
33use crate :: common:: { TestContext , uv_snapshot} ;
44use anyhow:: Result ;
5+ use assert_cmd:: assert:: OutputAssertExt ;
56use assert_fs:: fixture:: { FileWriteStr , PathChild , PathCreateDir } ;
67use insta:: assert_snapshot;
78use uv_python:: {
@@ -814,3 +815,63 @@ fn python_pin_with_comments() -> Result<()> {
814815
815816 Ok ( ( ) )
816817}
818+
819+ #[ test]
820+ fn python_pin_rm ( ) {
821+ let context: TestContext = TestContext :: new_with_versions ( & [ "3.12" ] ) ;
822+
823+ uv_snapshot ! ( context. filters( ) , context. python_pin( ) . arg( "--rm" ) , @r"
824+ success: false
825+ exit_code: 2
826+ ----- stdout -----
827+
828+ ----- stderr -----
829+ error: No Python version file found
830+ " ) ;
831+
832+ // Remove the local pin
833+ context. python_pin ( ) . arg ( "3.12" ) . assert ( ) . success ( ) ;
834+ uv_snapshot ! ( context. filters( ) , context. python_pin( ) . arg( "--rm" ) , @r"
835+ success: true
836+ exit_code: 0
837+ ----- stdout -----
838+ Removed Python version file at `.python-version`
839+
840+ ----- stderr -----
841+ " ) ;
842+
843+ uv_snapshot ! ( context. filters( ) , context. python_pin( ) . arg( "--rm" ) . arg( "--global" ) , @r"
844+ success: false
845+ exit_code: 2
846+ ----- stdout -----
847+
848+ ----- stderr -----
849+ error: No Python version file found
850+ " ) ;
851+
852+ // Global does not detect the local pin
853+ context. python_pin ( ) . arg ( "3.12" ) . assert ( ) . success ( ) ;
854+ uv_snapshot ! ( context. filters( ) , context. python_pin( ) . arg( "--rm" ) . arg( "--global" ) , @r"
855+ success: false
856+ exit_code: 2
857+ ----- stdout -----
858+
859+ ----- stderr -----
860+ error: No Python version file found
861+ " ) ;
862+
863+ context
864+ . python_pin ( )
865+ . arg ( "3.12" )
866+ . arg ( "--global" )
867+ . assert ( )
868+ . success ( ) ;
869+ uv_snapshot ! ( context. filters( ) , context. python_pin( ) . arg( "--rm" ) . arg( "--global" ) , @r"
870+ success: true
871+ exit_code: 0
872+ ----- stdout -----
873+ Removed Python version file at `[UV_USER_CONFIG_DIR]/.python-version`
874+
875+ ----- stderr -----
876+ " ) ;
877+ }
0 commit comments