Implement F541 (#12)

This commit is contained in:
Charlie Marsh 2022-08-16 10:47:13 -04:00 committed by GitHub
parent 3b1b53dacf
commit ddd554f9de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 7 deletions

View file

@ -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(