mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-29 03:02:55 +00:00
fix(tests): Refactor uv format tests (#15468)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / typos (push) Waiting to run
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / smoke test | linux aarch64 (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / test windows trampoline | aarch64 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / build binary | linux libc (push) Blocked by required conditions
CI / build binary | linux aarch64 (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | msrv (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | pyenv on wsl x86-64 (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | aarch64 windows implicit (push) Blocked by required conditions
CI / integration test | aarch64 windows explicit (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | pyodide on ubuntu (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | registries (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | graalpy on ubuntu (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | aarch64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks | walltime aarch64 linux (push) Blocked by required conditions
CI / benchmarks | instrumented (push) Blocked by required conditions
zizmor / Run zizmor (push) Waiting to run
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / typos (push) Waiting to run
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / smoke test | linux aarch64 (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / test windows trampoline | aarch64 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / build binary | linux libc (push) Blocked by required conditions
CI / build binary | linux aarch64 (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | msrv (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | pyenv on wsl x86-64 (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | aarch64 windows implicit (push) Blocked by required conditions
CI / integration test | aarch64 windows explicit (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | pyodide on ubuntu (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | registries (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | graalpy on ubuntu (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | aarch64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks | walltime aarch64 linux (push) Blocked by required conditions
CI / benchmarks | instrumented (push) Blocked by required conditions
zizmor / Run zizmor (push) Waiting to run
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
Closes #15458 ## Summary Refactor uv format tests to reduce noise.
This commit is contained in:
parent
7f1a464216
commit
6e802873cc
1 changed files with 53 additions and 106 deletions
|
|
@ -20,13 +20,9 @@ fn format_project() -> Result<()> {
|
||||||
|
|
||||||
// Create an unformatted Python file
|
// Create an unformatted Python file
|
||||||
let main_py = context.temp_dir.child("main.py");
|
let main_py = context.temp_dir.child("main.py");
|
||||||
main_py.write_str(indoc! {r#"
|
main_py.write_str(indoc! {r"
|
||||||
import sys
|
x = 1
|
||||||
def hello():
|
"})?;
|
||||||
print( "Hello, World!" )
|
|
||||||
if __name__=="__main__":
|
|
||||||
hello( )
|
|
||||||
"#})?;
|
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.format(), @r"
|
uv_snapshot!(context.filters(), context.format(), @r"
|
||||||
success: true
|
success: true
|
||||||
|
|
@ -40,17 +36,9 @@ fn format_project() -> Result<()> {
|
||||||
|
|
||||||
// Check that the file was formatted
|
// Check that the file was formatted
|
||||||
let formatted_content = fs_err::read_to_string(&main_py)?;
|
let formatted_content = fs_err::read_to_string(&main_py)?;
|
||||||
assert_snapshot!(formatted_content, @r#"
|
assert_snapshot!(formatted_content, @r"
|
||||||
import sys
|
x = 1
|
||||||
|
");
|
||||||
|
|
||||||
def hello():
|
|
||||||
print("Hello, World!")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
hello()
|
|
||||||
"#);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -70,13 +58,9 @@ fn format_from_project_root() -> Result<()> {
|
||||||
|
|
||||||
// Create an unformatted Python file
|
// Create an unformatted Python file
|
||||||
let main_py = context.temp_dir.child("main.py");
|
let main_py = context.temp_dir.child("main.py");
|
||||||
main_py.write_str(indoc! {r#"
|
main_py.write_str(indoc! {r"
|
||||||
import sys
|
x = 1
|
||||||
def hello():
|
"})?;
|
||||||
print( "Hello, World!" )
|
|
||||||
if __name__=="__main__":
|
|
||||||
hello( )
|
|
||||||
"#})?;
|
|
||||||
|
|
||||||
let subdir = context.temp_dir.child("subdir");
|
let subdir = context.temp_dir.child("subdir");
|
||||||
fs_err::create_dir_all(&subdir)?;
|
fs_err::create_dir_all(&subdir)?;
|
||||||
|
|
@ -94,17 +78,9 @@ fn format_from_project_root() -> Result<()> {
|
||||||
|
|
||||||
// Check that the file was formatted
|
// Check that the file was formatted
|
||||||
let formatted_content = fs_err::read_to_string(&main_py)?;
|
let formatted_content = fs_err::read_to_string(&main_py)?;
|
||||||
assert_snapshot!(formatted_content, @r#"
|
assert_snapshot!(formatted_content, @r"
|
||||||
import sys
|
x = 1
|
||||||
|
");
|
||||||
|
|
||||||
def hello():
|
|
||||||
print("Hello, World!")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
hello()
|
|
||||||
"#);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -124,23 +100,15 @@ fn format_relative_project() -> Result<()> {
|
||||||
|
|
||||||
// Create an unformatted Python file in the relative project
|
// Create an unformatted Python file in the relative project
|
||||||
let relative_project_main_py = context.temp_dir.child("project").child("main.py");
|
let relative_project_main_py = context.temp_dir.child("project").child("main.py");
|
||||||
relative_project_main_py.write_str(indoc! {r#"
|
relative_project_main_py.write_str(indoc! {r"
|
||||||
import sys
|
x = 1
|
||||||
def hello():
|
"})?;
|
||||||
print( "Hello, World!" )
|
|
||||||
if __name__=="__main__":
|
|
||||||
hello( )
|
|
||||||
"#})?;
|
|
||||||
|
|
||||||
// Create another unformatted Python file in the root directory
|
// Create another unformatted Python file in the root directory
|
||||||
let root_main_py = context.temp_dir.child("main.py");
|
let root_main_py = context.temp_dir.child("main.py");
|
||||||
root_main_py.write_str(indoc! {r#"
|
root_main_py.write_str(indoc! {r"
|
||||||
import sys
|
x = 1
|
||||||
def hello():
|
"})?;
|
||||||
print( "Hello, World!" )
|
|
||||||
if __name__=="__main__":
|
|
||||||
hello( )
|
|
||||||
"#})?;
|
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.format().arg("--project").arg("project"), @r"
|
uv_snapshot!(context.filters(), context.format().arg("--project").arg("project"), @r"
|
||||||
success: true
|
success: true
|
||||||
|
|
@ -154,27 +122,16 @@ fn format_relative_project() -> Result<()> {
|
||||||
|
|
||||||
// Check that the relative project file was formatted
|
// Check that the relative project file was formatted
|
||||||
let relative_project_content = fs_err::read_to_string(&relative_project_main_py)?;
|
let relative_project_content = fs_err::read_to_string(&relative_project_main_py)?;
|
||||||
assert_snapshot!(relative_project_content, @r#"
|
assert_snapshot!(relative_project_content, @r"
|
||||||
import sys
|
x = 1
|
||||||
|
");
|
||||||
|
|
||||||
def hello():
|
|
||||||
print("Hello, World!")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
hello()
|
|
||||||
"#);
|
|
||||||
|
|
||||||
// Check that the root file was not formatted
|
// Check that the root file was not formatted
|
||||||
let root_content = fs_err::read_to_string(&root_main_py)?;
|
let root_content = fs_err::read_to_string(&root_main_py)?;
|
||||||
assert_snapshot!(root_content, @r#"
|
assert_snapshot!(root_content, @r"
|
||||||
import sys
|
x = 1
|
||||||
def hello():
|
");
|
||||||
print( "Hello, World!" )
|
|
||||||
if __name__=="__main__":
|
|
||||||
hello( )
|
|
||||||
"#);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,10 +150,9 @@ fn format_check() -> Result<()> {
|
||||||
|
|
||||||
// Create an unformatted Python file
|
// Create an unformatted Python file
|
||||||
let main_py = context.temp_dir.child("main.py");
|
let main_py = context.temp_dir.child("main.py");
|
||||||
main_py.write_str(indoc! {r#"
|
main_py.write_str(indoc! {r"
|
||||||
def hello():
|
x = 1
|
||||||
print( "Hello, World!" )
|
"})?;
|
||||||
"#})?;
|
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.format().arg("--check"), @r"
|
uv_snapshot!(context.filters(), context.format().arg("--check"), @r"
|
||||||
success: false
|
success: false
|
||||||
|
|
@ -211,10 +167,9 @@ fn format_check() -> Result<()> {
|
||||||
|
|
||||||
// Verify the file wasn't modified
|
// Verify the file wasn't modified
|
||||||
let content = fs_err::read_to_string(&main_py)?;
|
let content = fs_err::read_to_string(&main_py)?;
|
||||||
assert_snapshot!(content, @r#"
|
assert_snapshot!(content, @r"
|
||||||
def hello():
|
x = 1
|
||||||
print( "Hello, World!" )
|
");
|
||||||
"#);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -234,10 +189,9 @@ fn format_diff() -> Result<()> {
|
||||||
|
|
||||||
// Create an unformatted Python file
|
// Create an unformatted Python file
|
||||||
let main_py = context.temp_dir.child("main.py");
|
let main_py = context.temp_dir.child("main.py");
|
||||||
main_py.write_str(indoc! {r#"
|
main_py.write_str(indoc! {r"
|
||||||
def hello():
|
x = 1
|
||||||
print( "Hello, World!" )
|
"})?;
|
||||||
"#})?;
|
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.format().arg("--diff"), @r#"
|
uv_snapshot!(context.filters(), context.format().arg("--diff"), @r#"
|
||||||
success: false
|
success: false
|
||||||
|
|
@ -245,11 +199,9 @@ fn format_diff() -> Result<()> {
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
--- main.py
|
--- main.py
|
||||||
+++ main.py
|
+++ main.py
|
||||||
@@ -1,2 +1,2 @@
|
@@ -1 +1 @@
|
||||||
-def hello():
|
-x = 1
|
||||||
- print( "Hello, World!" )
|
+x = 1
|
||||||
+def hello():
|
|
||||||
+ print("Hello, World!")
|
|
||||||
|
|
||||||
|
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
|
|
@ -259,10 +211,9 @@ fn format_diff() -> Result<()> {
|
||||||
|
|
||||||
// Verify the file wasn't modified
|
// Verify the file wasn't modified
|
||||||
let content = fs_err::read_to_string(&main_py)?;
|
let content = fs_err::read_to_string(&main_py)?;
|
||||||
assert_snapshot!(content, @r#"
|
assert_snapshot!(content, @r"
|
||||||
def hello():
|
x = 1
|
||||||
print( "Hello, World!" )
|
");
|
||||||
"#);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -323,16 +274,14 @@ fn format_specific_files() -> Result<()> {
|
||||||
|
|
||||||
// Create multiple unformatted Python files
|
// Create multiple unformatted Python files
|
||||||
let main_py = context.temp_dir.child("main.py");
|
let main_py = context.temp_dir.child("main.py");
|
||||||
main_py.write_str(indoc! {r#"
|
main_py.write_str(indoc! {r"
|
||||||
def main():
|
x = 1
|
||||||
print( "Main" )
|
"})?;
|
||||||
"#})?;
|
|
||||||
|
|
||||||
let utils_py = context.temp_dir.child("utils.py");
|
let utils_py = context.temp_dir.child("utils.py");
|
||||||
utils_py.write_str(indoc! {r#"
|
utils_py.write_str(indoc! {r"
|
||||||
def utils():
|
x = 1
|
||||||
print( "utils" )
|
"})?;
|
||||||
"#})?;
|
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.format().arg("--").arg("main.py"), @r"
|
uv_snapshot!(context.filters(), context.format().arg("--").arg("main.py"), @r"
|
||||||
success: true
|
success: true
|
||||||
|
|
@ -345,17 +294,15 @@ fn format_specific_files() -> Result<()> {
|
||||||
");
|
");
|
||||||
|
|
||||||
let main_content = fs_err::read_to_string(&main_py)?;
|
let main_content = fs_err::read_to_string(&main_py)?;
|
||||||
assert_snapshot!(main_content, @r#"
|
assert_snapshot!(main_content, @r"
|
||||||
def main():
|
x = 1
|
||||||
print("Main")
|
");
|
||||||
"#);
|
|
||||||
|
|
||||||
// Unchanged
|
// Unchanged
|
||||||
let utils_content = fs_err::read_to_string(&utils_py)?;
|
let utils_content = fs_err::read_to_string(&utils_py)?;
|
||||||
assert_snapshot!(utils_content, @r#"
|
assert_snapshot!(utils_content, @r"
|
||||||
def utils():
|
x = 1
|
||||||
print( "utils" )
|
");
|
||||||
"#);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -375,7 +322,7 @@ fn format_version_option() -> Result<()> {
|
||||||
|
|
||||||
let main_py = context.temp_dir.child("main.py");
|
let main_py = context.temp_dir.child("main.py");
|
||||||
main_py.write_str(indoc! {r"
|
main_py.write_str(indoc! {r"
|
||||||
def hello(): pass
|
x = 1
|
||||||
"})?;
|
"})?;
|
||||||
|
|
||||||
// Run format with specific Ruff version
|
// Run format with specific Ruff version
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue