mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
[ty] Add regression test for fixed pyvenv.cfg
parsing bug (#18157)
Some checks failed
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Has been cancelled
Some checks failed
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Has been cancelled
This commit is contained in:
parent
b86960f18c
commit
dd04ca7f58
1 changed files with 31 additions and 0 deletions
|
@ -626,6 +626,7 @@ mod tests {
|
||||||
struct VirtualEnvironmentTestCase {
|
struct VirtualEnvironmentTestCase {
|
||||||
system_site_packages: bool,
|
system_site_packages: bool,
|
||||||
pyvenv_cfg_version_field: Option<&'static str>,
|
pyvenv_cfg_version_field: Option<&'static str>,
|
||||||
|
command_field: Option<&'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PythonEnvironmentTestCase {
|
struct PythonEnvironmentTestCase {
|
||||||
|
@ -677,6 +678,7 @@ mod tests {
|
||||||
let Some(VirtualEnvironmentTestCase {
|
let Some(VirtualEnvironmentTestCase {
|
||||||
pyvenv_cfg_version_field,
|
pyvenv_cfg_version_field,
|
||||||
system_site_packages,
|
system_site_packages,
|
||||||
|
command_field,
|
||||||
}) = virtual_env
|
}) = virtual_env
|
||||||
else {
|
else {
|
||||||
return system_install_sys_prefix;
|
return system_install_sys_prefix;
|
||||||
|
@ -703,6 +705,10 @@ mod tests {
|
||||||
pyvenv_cfg_contents.push_str(version_field);
|
pyvenv_cfg_contents.push_str(version_field);
|
||||||
pyvenv_cfg_contents.push('\n');
|
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:
|
// Deliberately using weird casing here to test that our pyvenv.cfg parsing is case-insensitive:
|
||||||
if *system_site_packages {
|
if *system_site_packages {
|
||||||
pyvenv_cfg_contents.push_str("include-system-site-packages = TRuE\n");
|
pyvenv_cfg_contents.push_str("include-system-site-packages = TRuE\n");
|
||||||
|
@ -934,6 +940,7 @@ mod tests {
|
||||||
virtual_env: Some(VirtualEnvironmentTestCase {
|
virtual_env: Some(VirtualEnvironmentTestCase {
|
||||||
system_site_packages: false,
|
system_site_packages: false,
|
||||||
pyvenv_cfg_version_field: None,
|
pyvenv_cfg_version_field: None,
|
||||||
|
command_field: None,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
test.run();
|
test.run();
|
||||||
|
@ -949,6 +956,7 @@ mod tests {
|
||||||
virtual_env: Some(VirtualEnvironmentTestCase {
|
virtual_env: Some(VirtualEnvironmentTestCase {
|
||||||
system_site_packages: false,
|
system_site_packages: false,
|
||||||
pyvenv_cfg_version_field: Some("version = 3.12"),
|
pyvenv_cfg_version_field: Some("version = 3.12"),
|
||||||
|
command_field: None,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
test.run();
|
test.run();
|
||||||
|
@ -964,6 +972,7 @@ mod tests {
|
||||||
virtual_env: Some(VirtualEnvironmentTestCase {
|
virtual_env: Some(VirtualEnvironmentTestCase {
|
||||||
system_site_packages: false,
|
system_site_packages: false,
|
||||||
pyvenv_cfg_version_field: Some("version_info = 3.12"),
|
pyvenv_cfg_version_field: Some("version_info = 3.12"),
|
||||||
|
command_field: None,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
test.run();
|
test.run();
|
||||||
|
@ -979,6 +988,7 @@ mod tests {
|
||||||
virtual_env: Some(VirtualEnvironmentTestCase {
|
virtual_env: Some(VirtualEnvironmentTestCase {
|
||||||
system_site_packages: false,
|
system_site_packages: false,
|
||||||
pyvenv_cfg_version_field: Some("version_info = 3.12.0rc2"),
|
pyvenv_cfg_version_field: Some("version_info = 3.12.0rc2"),
|
||||||
|
command_field: None,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
test.run();
|
test.run();
|
||||||
|
@ -994,6 +1004,7 @@ mod tests {
|
||||||
virtual_env: Some(VirtualEnvironmentTestCase {
|
virtual_env: Some(VirtualEnvironmentTestCase {
|
||||||
system_site_packages: false,
|
system_site_packages: false,
|
||||||
pyvenv_cfg_version_field: Some("version_info = 3.13"),
|
pyvenv_cfg_version_field: Some("version_info = 3.13"),
|
||||||
|
command_field: None,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
test.run();
|
test.run();
|
||||||
|
@ -1009,6 +1020,7 @@ mod tests {
|
||||||
virtual_env: Some(VirtualEnvironmentTestCase {
|
virtual_env: Some(VirtualEnvironmentTestCase {
|
||||||
system_site_packages: true,
|
system_site_packages: true,
|
||||||
pyvenv_cfg_version_field: Some("version_info = 3.13"),
|
pyvenv_cfg_version_field: Some("version_info = 3.13"),
|
||||||
|
command_field: None,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
test.run();
|
test.run();
|
||||||
|
@ -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]
|
#[test]
|
||||||
fn parsing_pyvenv_cfg_with_key_but_no_value_fails() {
|
fn parsing_pyvenv_cfg_with_key_but_no_value_fails() {
|
||||||
let system = TestSystem::default();
|
let system = TestSystem::default();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue