mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Implement F541 (#12)
This commit is contained in:
parent
3b1b53dacf
commit
ddd554f9de
5 changed files with 69 additions and 7 deletions
|
@ -44,7 +44,9 @@ mod tests {
|
|||
use rustpython_parser::ast::Location;
|
||||
|
||||
use crate::cache;
|
||||
use crate::checks::CheckKind::{DuplicateArgumentName, IfTuple, ImportStarUsage, LineTooLong};
|
||||
use crate::checks::CheckKind::{
|
||||
DuplicateArgumentName, FStringMissingPlaceholders, IfTuple, ImportStarUsage, LineTooLong,
|
||||
};
|
||||
use crate::linter::check_path;
|
||||
use crate::message::Message;
|
||||
|
||||
|
@ -79,6 +81,37 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f_string_missing_placeholders() -> Result<()> {
|
||||
let actual = check_path(
|
||||
&Path::new("./resources/test/src/f_string_missing_placeholders.py"),
|
||||
&cache::Mode::None,
|
||||
)?;
|
||||
let expected = vec![
|
||||
Message {
|
||||
kind: FStringMissingPlaceholders,
|
||||
location: Location::new(4, 7),
|
||||
filename: "./resources/test/src/f_string_missing_placeholders.py".to_string(),
|
||||
},
|
||||
Message {
|
||||
kind: FStringMissingPlaceholders,
|
||||
location: Location::new(5, 7),
|
||||
filename: "./resources/test/src/f_string_missing_placeholders.py".to_string(),
|
||||
},
|
||||
Message {
|
||||
kind: FStringMissingPlaceholders,
|
||||
location: Location::new(7, 7),
|
||||
filename: "./resources/test/src/f_string_missing_placeholders.py".to_string(),
|
||||
},
|
||||
];
|
||||
assert_eq!(actual.len(), expected.len());
|
||||
for i in 1..actual.len() {
|
||||
assert_eq!(actual[i], expected[i]);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn if_tuple() -> Result<()> {
|
||||
let actual = check_path(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue