Skip to content

Commit a7d7af8

Browse files
karthiknadigCopilot
andcommitted
test: normalize cached Poetry fixture identity (PR #566)
Seed the cache with production-normalized identities and assert an explicit Windows executable case alias. Preserve the missing-manager/project setup so fidelity still depends on cached metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 74c93c9 commit a7d7af8

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

‎crates/pet-poetry/src/lib.rs‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,30 @@ mod tests {
615615
std::fs::write(&executable, "").unwrap();
616616
std::fs::write(executable.parent().unwrap().join("activate"), "").unwrap();
617617

618+
let cached_identity = PythonEnv::new(
619+
executable.clone(),
620+
Some(prefix.clone()),
621+
Some("3.12.0".to_string()),
622+
);
623+
#[cfg(windows)]
624+
let requested_identity = {
625+
let case_alias_prefix = temp_dir.path().join("project-env");
626+
let case_alias_executable = case_alias_prefix.join("scripts").join("PYTHON.EXE");
627+
assert_ne!(case_alias_executable, executable);
628+
629+
let identity = PythonEnv::new(
630+
case_alias_executable,
631+
Some(case_alias_prefix),
632+
Some("3.12.0".to_string()),
633+
);
634+
assert_eq!(identity.executable, cached_identity.executable);
635+
assert_eq!(identity.prefix, cached_identity.prefix);
636+
identity
637+
};
638+
#[cfg(not(windows))]
639+
let requested_identity =
640+
PythonEnv::new(executable, Some(prefix), Some("3.12.0".to_string()));
641+
618642
let environment = EnvironmentApi::new();
619643
let poetry = Poetry::from(&environment);
620644
let workspace = temp_dir.path().join("removed-project");
@@ -636,12 +660,12 @@ mod tests {
636660
.replace(LocatorResult {
637661
managers: vec![manager.clone()],
638662
environments: vec![PythonEnvironment {
639-
executable: Some(executable.clone()),
640-
prefix: Some(prefix.clone()),
663+
executable: Some(cached_identity.executable.clone()),
664+
prefix: cached_identity.prefix.clone(),
641665
kind: Some(PythonEnvironmentKind::Poetry),
642666
manager: Some(manager.clone()),
643667
project: Some(workspace.clone()),
644-
symlinks: Some(vec![executable.clone()]),
668+
symlinks: Some(vec![cached_identity.executable]),
645669
..Default::default()
646670
}],
647671
});
@@ -651,11 +675,7 @@ mod tests {
651675
poetry.configure(&config);
652676

653677
let identified = poetry
654-
.try_from(&PythonEnv::new(
655-
executable,
656-
Some(prefix),
657-
Some("3.12.0".to_string()),
658-
))
678+
.try_from(&requested_identity)
659679
.expect("cached Poetry environment must remain identifiable");
660680
assert_eq!(identified.manager, Some(manager));
661681
assert_eq!(identified.project, Some(workspace));

0 commit comments

Comments
 (0)