Skip to content

Commit 327cafb

Browse files
committed
chore: add tests, snapshots for preview
1 parent b0ea088 commit 327cafb

5 files changed

+2112
-0
lines changed

crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,48 @@ mod tests {
8080
Ok(())
8181
}
8282

83+
#[test_case(Path::new("full_name.py"))]
84+
#[test_case(Path::new("import_as.py"))]
85+
#[test_case(Path::new("import_from_as.py"))]
86+
#[test_case(Path::new("import_from.py"))]
87+
fn preview_rules(path: &Path) -> Result<()> {
88+
let snapshot = format!("preview_{}", path.to_string_lossy());
89+
let diagnostics = test_path(
90+
Path::new("flake8_use_pathlib").join(path).as_path(),
91+
&settings::LinterSettings {
92+
preview: PreviewMode::Enabled,
93+
..settings::LinterSettings::for_rules(vec![
94+
Rule::OsPathAbspath,
95+
Rule::OsChmod,
96+
Rule::OsMkdir,
97+
Rule::OsMakedirs,
98+
Rule::OsRename,
99+
Rule::OsReplace,
100+
Rule::OsRmdir,
101+
Rule::OsRemove,
102+
Rule::OsUnlink,
103+
Rule::OsGetcwd,
104+
Rule::OsPathExists,
105+
Rule::OsPathExpanduser,
106+
Rule::OsPathIsdir,
107+
Rule::OsPathIsfile,
108+
Rule::OsPathIslink,
109+
Rule::OsReadlink,
110+
Rule::OsStat,
111+
Rule::OsPathIsabs,
112+
Rule::OsPathJoin,
113+
Rule::OsPathBasename,
114+
Rule::OsPathDirname,
115+
Rule::OsPathSamefile,
116+
Rule::OsPathSplitext,
117+
Rule::BuiltinOpen,
118+
])
119+
},
120+
)?;
121+
assert_diagnostics!(snapshot, diagnostics);
122+
Ok(())
123+
}
124+
83125
#[test_case(Rule::OsPathGetsize, Path::new("PTH202.py"))]
84126
#[test_case(Rule::OsPathGetsize, Path::new("PTH202_2.py"))]
85127
#[test_case(Rule::OsPathGetatime, Path::new("PTH203.py"))]

0 commit comments

Comments
 (0)