Skip to content

Commit 5da99d8

Browse files
authored
test: add virtualenvwrapper negative coverage (#425)
Summary: - Add coverage that paths under `WORKON_HOME` are not enough to classify an environment as virtualenvwrapper. - Verify folders must still satisfy virtualenv detection before identification succeeds. - Covers a utility-crate slice from the #389 coverage plan. Validation: - cargo test -p pet-virtualenvwrapper - cargo fmt --all - cargo clippy --all -- -D warnings Refs #389
1 parent 172d4b1 commit 5da99d8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

crates/pet-virtualenvwrapper/src/environments.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,29 @@ mod tests {
135135
fs::remove_dir_all(outside_prefix.parent().unwrap()).unwrap();
136136
}
137137

138+
#[test]
139+
fn is_virtualenvwrapper_rejects_non_virtualenv_under_workon_home() {
140+
let workon_home = create_test_dir("workon-home");
141+
let prefix = workon_home.join("not-a-virtualenv");
142+
let scripts_dir = prefix.join(if cfg!(windows) { "Scripts" } else { "bin" });
143+
fs::create_dir_all(&scripts_dir).unwrap();
144+
let executable = scripts_dir.join(if cfg!(windows) {
145+
"python.exe"
146+
} else {
147+
"python"
148+
});
149+
fs::write(&executable, b"").unwrap();
150+
let env = PythonEnv::new(executable, Some(prefix), None);
151+
let env_variables = EnvVariables {
152+
home: None,
153+
workon_home: Some(workon_home.to_string_lossy().to_string()),
154+
};
155+
156+
assert!(!is_virtualenvwrapper(&env, &env_variables));
157+
158+
fs::remove_dir_all(workon_home).unwrap();
159+
}
160+
138161
#[cfg(windows)]
139162
#[test]
140163
fn is_virtualenvwrapper_accepts_env_under_symlinked_workon_home() {

0 commit comments

Comments
 (0)