From 302db93cc52c47a62b94ce6aa5a96c7ba45edb4f Mon Sep 17 00:00:00 2001 From: j178 <10510431+j178@users.noreply.github.com> Date: Wed, 24 Jul 2024 02:04:04 +0800 Subject: [PATCH] Simplify test --- crates/uv/tests/python_pin.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/uv/tests/python_pin.rs b/crates/uv/tests/python_pin.rs index f42d49342a46..416b8c388aa0 100644 --- a/crates/uv/tests/python_pin.rs +++ b/crates/uv/tests/python_pin.rs @@ -1,7 +1,7 @@ #![cfg(all(feature = "python", feature = "pypi"))] use anyhow::Result; -use assert_fs::fixture::{FileWriteStr, PathChild, PathCreateDir}; +use assert_fs::fixture::{FileWriteStr, PathChild}; use common::{uv_snapshot, TestContext}; use insta::assert_snapshot; use uv_python::{ @@ -635,12 +635,16 @@ fn python_pin_resolve() { fn python_pin_with_comments() -> Result<()> { let context = TestContext::new_with_versions(&[]); - let child = context.temp_dir.child("foo"); - child.create_dir_all()?; + let content = indoc::indoc! {r" + 3.12 + + # 3.11 + 3.10 + "}; - let version_file = child.child(PYTHON_VERSION_FILENAME); - version_file.write_str("3.12\n\n# 3.11\n3.10\n\n")?; - uv_snapshot!(context.filters(), context.python_pin().current_dir(&child), @r###" + let version_file = context.temp_dir.child(PYTHON_VERSION_FILENAME); + version_file.write_str(content)?; + uv_snapshot!(context.filters(), context.python_pin(), @r###" success: true exit_code: 0 ----- stdout ----- @@ -648,13 +652,11 @@ fn python_pin_with_comments() -> Result<()> { ----- stderr ----- "###); + fs_err::remove_file(version_file)?; - let child = context.temp_dir.child("bar"); - child.create_dir_all()?; - - let versions_file = child.child(PYTHON_VERSIONS_FILENAME); - versions_file.write_str("3.12\n\n# 3.11\n3.10\n\n")?; - uv_snapshot!(context.filters(), context.python_pin().current_dir(&child), @r###" + let versions_file = context.temp_dir.child(PYTHON_VERSIONS_FILENAME); + versions_file.write_str(content)?; + uv_snapshot!(context.filters(), context.python_pin(), @r###" success: true exit_code: 0 ----- stdout -----