Skip to content

Commit 387e7c9

Browse files
authored
test: add pixi prefix coverage (#424)
Summary: - Add coverage for deriving a Pixi prefix from a direct-child Python executable. - Complements existing explicit-prefix and nested `bin`/`Scripts` executable tests. - Covers a small utility-crate slice from the #389 coverage plan. Validation: - cargo test -p pet-pixi - cargo fmt --all - cargo clippy --all -- -D warnings Refs #389
1 parent 5da99d8 commit 387e7c9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/pet-pixi/src/lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,33 @@ mod tests {
192192
);
193193
}
194194

195+
#[test]
196+
fn try_from_derives_pixi_prefix_from_direct_child_executable() {
197+
let temp_dir = TempDir::new().unwrap();
198+
let prefix = create_pixi_prefix(&temp_dir);
199+
let executable = prefix.join(if cfg!(windows) {
200+
"python.exe"
201+
} else {
202+
"python"
203+
});
204+
fs::write(&executable, b"").unwrap();
205+
let locator = Pixi::new();
206+
let env = PythonEnv::new(executable, None, None);
207+
208+
let pixi_env = locator.try_from(&env).unwrap();
209+
210+
assert_eq!(pixi_env.kind, Some(PythonEnvironmentKind::Pixi));
211+
assert_eq!(
212+
pixi_env
213+
.prefix
214+
.as_deref()
215+
.map(fs::canonicalize)
216+
.transpose()
217+
.unwrap(),
218+
Some(fs::canonicalize(prefix).unwrap())
219+
);
220+
}
221+
195222
#[test]
196223
fn try_from_rejects_non_pixi_environments() {
197224
let temp_dir = TempDir::new().unwrap();

0 commit comments

Comments
 (0)