Skip to content

Commit c4a0878

Browse files
authored
Add regression test for parent noqa (astral-sh#17783)
Summary -- Adds a regression test for astral-sh#2253 after I tried to delete the fix from astral-sh#2464.
1 parent 91481a8 commit c4a0878

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

crates/ruff/tests/lint.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,40 @@ def first_square():
19001900
Ok(())
19011901
}
19021902

1903+
/// Regression test for <https://github.com/astral-sh/ruff/issues/2253>
1904+
#[test]
1905+
fn add_noqa_parent() -> Result<()> {
1906+
let tempdir = TempDir::new()?;
1907+
let test_path = tempdir.path().join("noqa.py");
1908+
fs::write(
1909+
&test_path,
1910+
r#"
1911+
from foo import ( # noqa: F401
1912+
bar
1913+
)
1914+
"#,
1915+
)?;
1916+
1917+
insta::with_settings!({
1918+
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
1919+
}, {
1920+
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
1921+
.args(STDIN_BASE_OPTIONS)
1922+
.arg("--add-noqa")
1923+
.arg("--select=F401")
1924+
.arg("noqa.py")
1925+
.current_dir(&tempdir), @r"
1926+
success: true
1927+
exit_code: 0
1928+
----- stdout -----
1929+
1930+
----- stderr -----
1931+
");
1932+
});
1933+
1934+
Ok(())
1935+
}
1936+
19031937
/// Infer `3.11` from `requires-python` in `pyproject.toml`.
19041938
#[test]
19051939
fn requires_python() -> Result<()> {

0 commit comments

Comments
 (0)