From ae8c7d11e3ce6c1a29e03ebb57f025bd9a368ca7 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 3 Jan 2024 21:16:13 -0400 Subject: [PATCH] Use `create_venv_py312` in pip-uninstall tests (#764) --- crates/puffin-cli/tests/pip_uninstall.rs | 49 +++--------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/crates/puffin-cli/tests/pip_uninstall.rs b/crates/puffin-cli/tests/pip_uninstall.rs index 8e7dc4baa..672356160 100644 --- a/crates/puffin-cli/tests/pip_uninstall.rs +++ b/crates/puffin-cli/tests/pip_uninstall.rs @@ -5,9 +5,10 @@ use assert_cmd::prelude::*; use assert_fs::prelude::*; use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; -use crate::common::create_venv_py312; use common::{BIN_NAME, INSTA_FILTERS}; +use crate::common::create_venv_py312; + mod common; #[test] @@ -221,17 +222,7 @@ dependencies = ["flask==1.0.x"] fn uninstall() -> Result<()> { let temp_dir = assert_fs::TempDir::new()?; let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let venv = create_venv_py312(&temp_dir, &cache_dir); let requirements_txt = temp_dir.child("requirements.txt"); requirements_txt.touch()?; @@ -351,7 +342,7 @@ fn missing_record() -> Result<()> { fn uninstall_editable_by_name() -> Result<()> { let temp_dir = assert_fs::TempDir::new()?; let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); + let venv = create_venv_py312(&temp_dir, &cache_dir); let current_dir = std::env::current_dir()?; let workspace_dir = current_dir.join("..").join("..").canonicalize()?; @@ -359,16 +350,6 @@ fn uninstall_editable_by_name() -> Result<()> { let mut filters = INSTA_FILTERS.to_vec(); filters.push((workspace_dir.to_str().unwrap(), "[WORKSPACE_DIR]")); - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); - let requirements_txt = temp_dir.child("requirements.txt"); requirements_txt.touch()?; requirements_txt.write_str("-e ../../scripts/editable-installs/poetry_editable")?; @@ -422,7 +403,7 @@ fn uninstall_editable_by_name() -> Result<()> { fn uninstall_editable_by_path() -> Result<()> { let temp_dir = assert_fs::TempDir::new()?; let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); + let venv = create_venv_py312(&temp_dir, &cache_dir); let current_dir = std::env::current_dir()?; let workspace_dir = current_dir.join("..").join("..").canonicalize()?; @@ -430,15 +411,6 @@ fn uninstall_editable_by_path() -> Result<()> { let mut filters = INSTA_FILTERS.to_vec(); filters.push((workspace_dir.to_str().unwrap(), "[WORKSPACE_DIR]")); - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); - let requirements_txt = temp_dir.child("requirements.txt"); requirements_txt.touch()?; requirements_txt.write_str("-e ../../scripts/editable-installs/poetry_editable")?; @@ -492,7 +464,7 @@ fn uninstall_editable_by_path() -> Result<()> { fn uninstall_duplicate_editable() -> Result<()> { let temp_dir = assert_fs::TempDir::new()?; let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); + let venv = create_venv_py312(&temp_dir, &cache_dir); let current_dir = std::env::current_dir()?; let workspace_dir = current_dir.join("..").join("..").canonicalize()?; @@ -500,15 +472,6 @@ fn uninstall_duplicate_editable() -> Result<()> { let mut filters = INSTA_FILTERS.to_vec(); filters.push((workspace_dir.to_str().unwrap(), "[WORKSPACE_DIR]")); - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); - let requirements_txt = temp_dir.child("requirements.txt"); requirements_txt.touch()?; requirements_txt.write_str("-e ../../scripts/editable-installs/poetry_editable")?;