diff --git a/crates/uv/tests/it/python_install.rs b/crates/uv/tests/it/python_install.rs index e8a49dc88..906c3ce7e 100644 --- a/crates/uv/tests/it/python_install.rs +++ b/crates/uv/tests/it/python_install.rs @@ -3955,6 +3955,19 @@ fn python_install_upgrade_version_file() { #[test] fn python_install_compile_bytecode() -> anyhow::Result<()> { + fn count_files_by_ext(dir: &Path, extension: &str) -> anyhow::Result { + let mut count = 0; + let walker = WalkDir::new(dir).into_iter(); + for entry in walker { + let entry = entry?; + let path = entry.path(); + if entry.metadata()?.is_file() && path.extension().is_some_and(|ext| ext == extension) { + count += 1; + } + } + Ok(count) + } + let context: TestContext = TestContext::new_with_versions(&[]) .with_filtered_python_keys() .with_filtered_exe_suffix() @@ -3988,20 +4001,9 @@ fn python_install_compile_bytecode() -> anyhow::Result<()> { .join("python3.14"); // And the count should match - let count = { - let mut count = 0; - let walker = WalkDir::new(stdlib).into_iter(); - for entry in walker { - let entry = entry?; - let path = entry.path(); - if entry.metadata()?.is_file() && path.extension().is_some_and(|ext| ext == "pyc") { - count += 1; - } - } - count - }; - - insta::assert_snapshot!(count.to_string(), @"1052"); + let pyc_count = count_files_by_ext(&stdlib, "pyc")?; + let py_count = count_files_by_ext(&stdlib, "py")?; + assert_eq!(pyc_count, py_count); // Attempting to install with --compile-bytecode should (currently) // unconditionally re-run the bytecode compiler