Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jul 23, 2024
1 parent b5c3f93 commit ae2691e
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions crates/uv/tests/python_pin.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#![cfg(all(feature = "python", feature = "pypi"))]

use assert_fs::fixture::{FileWriteStr as _, PathChild as _};
use anyhow::Result;
use assert_fs::fixture::{FileWriteStr, PathChild, PathCreateDir};
use common::{uv_snapshot, TestContext};
use insta::assert_snapshot;
use uv_python::{
platform::{Arch, Os},
PYTHON_VERSION_FILENAME,
PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME,
};

mod common;
Expand Down Expand Up @@ -629,3 +630,39 @@ fn python_pin_resolve() {
"###);
});
}

#[test]
fn test_read_python_version() -> Result<()> {
let context = TestContext::new_with_versions(&[]);

let child = context.temp_dir.child("foo");
child.create_dir_all()?;

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###"
success: true
exit_code: 0
----- stdout -----
3.12
----- stderr -----
"###);

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###"
success: true
exit_code: 0
----- stdout -----
3.12
3.10
----- stderr -----
"###);

Ok(())
}

0 comments on commit ae2691e

Please sign in to comment.