Add regression test for parent noqa (#17783)

Summary
--

Adds a regression test for #2253 after I tried to delete the fix from
#2464.
This commit is contained in:
Brent Westbrook 2025-05-03 11:38:31 -04:00 committed by GitHub
parent 91481a8be7
commit c4a08782cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1900,6 +1900,40 @@ def first_square():
Ok(())
}
/// Regression test for <https://github.com/astral-sh/ruff/issues/2253>
#[test]
fn add_noqa_parent() -> Result<()> {
let tempdir = TempDir::new()?;
let test_path = tempdir.path().join("noqa.py");
fs::write(
&test_path,
r#"
from foo import ( # noqa: F401
bar
)
"#,
)?;
insta::with_settings!({
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
.arg("--add-noqa")
.arg("--select=F401")
.arg("noqa.py")
.current_dir(&tempdir), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
");
});
Ok(())
}
/// Infer `3.11` from `requires-python` in `pyproject.toml`.
#[test]
fn requires_python() -> Result<()> {