[flake8-datetimez] Usages of datetime.max/datetime.min (DTZ901) (#14288)

## Summary

Resolves #13217.

## Test Plan

`cargo nextest run` and `cargo insta test`.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
InSync 2024-11-13 03:36:07 +07:00 committed by GitHub
parent bd30701980
commit 5c548dcc04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 249 additions and 3 deletions

View file

@ -9,6 +9,7 @@ mod tests {
use test_case::test_case;
use crate::registry::Rule;
use crate::settings::types::PreviewMode;
use crate::test::test_path;
use crate::{assert_messages, settings};
@ -30,4 +31,18 @@ mod tests {
assert_messages!(snapshot, diagnostics);
Ok(())
}
#[test_case(Rule::DatetimeMinMax, Path::new("DTZ901.py"))]
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path(
Path::new("flake8_datetimez").join(path).as_path(),
&settings::LinterSettings {
preview: PreviewMode::Enabled,
..settings::LinterSettings::for_rule(rule_code)
},
)?;
assert_messages!(snapshot, diagnostics);
Ok(())
}
}