Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/ty_python_semantic/src/site_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -934,6 +940,7 @@ mod tests {
virtual_env: Some(VirtualEnvironmentTestCase {
system_site_packages: false,
pyvenv_cfg_version_field: None,
command_field: None,
}),
};
test.run();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -1096,6 +1108,25 @@ mod tests {
);
}

/// See <https://github.com/astral-sh/ty/issues/430>
#[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();
Expand Down
Loading