diff --git a/crates/ty_python_semantic/src/site_packages.rs b/crates/ty_python_semantic/src/site_packages.rs index 5182ade9f95b7..b46dd6cb9948f 100644 --- a/crates/ty_python_semantic/src/site_packages.rs +++ b/crates/ty_python_semantic/src/site_packages.rs @@ -626,6 +626,7 @@ mod tests { struct VirtualEnvironmentTestCase { system_site_packages: bool, pyvenv_cfg_version_field: Option<&'static str>, + command_field: Option<&'static str>, } struct PythonEnvironmentTestCase { @@ -677,6 +678,7 @@ mod tests { let Some(VirtualEnvironmentTestCase { pyvenv_cfg_version_field, system_site_packages, + command_field, }) = virtual_env else { return system_install_sys_prefix; @@ -703,6 +705,10 @@ mod tests { pyvenv_cfg_contents.push_str(version_field); pyvenv_cfg_contents.push('\n'); } + if let Some(command_field) = command_field { + pyvenv_cfg_contents.push_str(command_field); + pyvenv_cfg_contents.push('\n'); + } // Deliberately using weird casing here to test that our pyvenv.cfg parsing is case-insensitive: if *system_site_packages { pyvenv_cfg_contents.push_str("include-system-site-packages = TRuE\n"); @@ -934,6 +940,7 @@ mod tests { virtual_env: Some(VirtualEnvironmentTestCase { system_site_packages: false, pyvenv_cfg_version_field: None, + command_field: None, }), }; test.run(); @@ -949,6 +956,7 @@ mod tests { virtual_env: Some(VirtualEnvironmentTestCase { system_site_packages: false, pyvenv_cfg_version_field: Some("version = 3.12"), + command_field: None, }), }; test.run(); @@ -964,6 +972,7 @@ mod tests { virtual_env: Some(VirtualEnvironmentTestCase { system_site_packages: false, pyvenv_cfg_version_field: Some("version_info = 3.12"), + command_field: None, }), }; test.run(); @@ -979,6 +988,7 @@ mod tests { virtual_env: Some(VirtualEnvironmentTestCase { system_site_packages: false, pyvenv_cfg_version_field: Some("version_info = 3.12.0rc2"), + command_field: None, }), }; test.run(); @@ -994,6 +1004,7 @@ mod tests { virtual_env: Some(VirtualEnvironmentTestCase { system_site_packages: false, pyvenv_cfg_version_field: Some("version_info = 3.13"), + command_field: None, }), }; test.run(); @@ -1009,6 +1020,7 @@ mod tests { virtual_env: Some(VirtualEnvironmentTestCase { system_site_packages: true, pyvenv_cfg_version_field: Some("version_info = 3.13"), + command_field: None, }), }; test.run(); @@ -1096,6 +1108,25 @@ mod tests { ); } + /// See + #[test] + fn parsing_pyvenv_cfg_with_equals_in_value() { + let test = PythonEnvironmentTestCase { + system: TestSystem::default(), + minor_version: 13, + free_threaded: true, + origin: SysPrefixPathOrigin::VirtualEnvVar, + virtual_env: Some(VirtualEnvironmentTestCase { + system_site_packages: true, + pyvenv_cfg_version_field: Some("version_info = 3.13"), + command_field: Some( + r#"command = /.pyenv/versions/3.13.3/bin/python3.13 -m venv --without-pip --prompt="python-default/3.13.3" /somewhere-else/python/virtualenvs/python-default/3.13.3"#, + ), + }), + }; + test.run(); + } + #[test] fn parsing_pyvenv_cfg_with_key_but_no_value_fails() { let system = TestSystem::default();