Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 30, 2024
1 parent 39afd1b commit 07f40f8
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions crates/uv/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1676,32 +1676,8 @@ fn run_isolated_incompatible_python() -> Result<()> {
fn run_compiled_python_file() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(indoc! { r#"
[project]
name = "foo"
version = "1.0.0"
requires-python = ">=3.8"
dependencies = ["anyio"]
"#
})?;

// If the script contains a PEP 723 tag, we should install its requirements.
let test_script = context.temp_dir.child("main.py");
test_script.write_str(indoc! { r#"
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "iniconfig",
# ]
# ///
import iniconfig
"#
})?;

let test_non_script = context.temp_dir.child("main.py");
test_non_script.write_str(indoc! { r#"
import idna
print("Hello, world!")
"#
})?;
Expand All @@ -1713,15 +1689,8 @@ fn run_compiled_python_file() -> Result<()> {
Hello, world!
----- stderr -----
Resolved 6 packages in [TIME]
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
+ anyio==4.3.0
+ idna==3.6
+ sniffio==1.3.1
"###);

let compiled_non_script = context.temp_dir.child("__pycache__/main.cpython-312.pyc");
let compile_output = context
.run()
.arg("python")
Expand All @@ -1735,15 +1704,15 @@ fn run_compiled_python_file() -> Result<()> {
"Failed to compile the python script"
);

let compiled_non_script = context.temp_dir.child("__pycache__/main.cpython-312.pyc");

uv_snapshot!(context.filters(), context.run().arg(compiled_non_script.path()), @r###"
success: true
exit_code: 0
----- stdout -----
Hello, world!
----- stderr -----
Resolved 6 packages in [TIME]
Audited 3 packages in [TIME]
"###);

Ok(())
Expand Down

0 comments on commit 07f40f8

Please sign in to comment.