@@ -110,18 +110,34 @@ mod tests {
110110 #[ test]
111111 fn test_is_venv_uv_dir_detects_uv_environment ( ) {
112112 // This test checks if we can detect a UV environment from pyvenv.cfg
113- let uv_env_path = PathBuf :: from ( "/tmp/test_uv_env" ) ;
114- assert ! ( is_venv_uv_dir( & uv_env_path) , "Should detect UV environment" ) ;
113+ use std:: fs;
114+ let test_dir = PathBuf :: from ( "/tmp/test_uv_env_venv_uv" ) ;
115+ fs:: create_dir_all ( & test_dir) . unwrap ( ) ;
116+ let pyvenv_cfg = test_dir. join ( "pyvenv.cfg" ) ;
117+ let contents = "home = /usr/bin/python3.12\n implementation = CPython\n uv = 0.8.14\n version_info = 3.12.11\n include-system-site-packages = false\n prompt = test-uv-env\n " ;
118+ fs:: write ( & pyvenv_cfg, contents) . unwrap ( ) ;
119+
120+ assert ! ( is_venv_uv_dir( & test_dir) , "Should detect UV environment" ) ;
121+
122+ fs:: remove_dir_all ( & test_dir) . ok ( ) ;
115123 }
116124
117125 #[ test]
118126 fn test_is_venv_uv_dir_does_not_detect_regular_environment ( ) {
119127 // This test checks if we can properly ignore regular venv environments
120- let regular_env_path = PathBuf :: from ( "/tmp/test_regular_env" ) ;
128+ use std:: fs;
129+ let test_dir = PathBuf :: from ( "/tmp/test_regular_env_venv_uv" ) ;
130+ fs:: create_dir_all ( & test_dir) . unwrap ( ) ;
131+ let pyvenv_cfg = test_dir. join ( "pyvenv.cfg" ) ;
132+ let contents = "home = /usr/bin/python3.12\n include-system-site-packages = false\n version = 3.13.5\n executable = /usr/bin/python3.12\n command = python -m venv /path/to/env\n " ;
133+ fs:: write ( & pyvenv_cfg, contents) . unwrap ( ) ;
134+
121135 assert ! (
122- !is_venv_uv_dir( & regular_env_path ) ,
136+ !is_venv_uv_dir( & test_dir ) ,
123137 "Should not detect regular venv as UV environment"
124138 ) ;
139+
140+ fs:: remove_dir_all ( & test_dir) . ok ( ) ;
125141 }
126142
127143 #[ test]
0 commit comments