Skip to content

Commit

Permalink
Remove custom tests in rules/ruff/mod.rs (#5033)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored and konstin committed Jun 13, 2023
1 parent 4f69cbf commit bdf6cb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
43 changes: 7 additions & 36 deletions crates/ruff/src/rules/ruff/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ mod tests {
use crate::test::{test_path, test_resource_path};
use crate::{assert_messages, settings};

#[test_case(Rule::CollectionLiteralConcatenation, Path::new("RUF005.py"))]
#[test_case(Rule::AsyncioDanglingTask, Path::new("RUF006.py"))]
#[test_case(Rule::CollectionLiteralConcatenation, Path::new("RUF005.py"))]
#[test_case(Rule::ExplicitFStringTypeConversion, Path::new("RUF010.py"))]
#[test_case(Rule::StaticKeyDictComprehension, Path::new("RUF011.py"))]
#[test_case(Rule::FunctionCallInDataclassDefaultArgument, Path::new("RUF009.py"))]
#[test_case(Rule::ImplicitOptional, Path::new("RUF013_0.py"))]
#[test_case(Rule::ImplicitOptional, Path::new("RUF013_1.py"))]
#[test_case(Rule::MutableClassDefault, Path::new("RUF012.py"))]
#[test_case(Rule::MutableDataclassDefault, Path::new("RUF008.py"))]
#[test_case(Rule::PairwiseOverZipped, Path::new("RUF007.py"))]
#[test_case(Rule::StaticKeyDictComprehension, Path::new("RUF011.py"))]
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path(
Expand All @@ -38,7 +42,7 @@ mod tests {

#[test_case(Path::new("RUF013_0.py"))]
#[test_case(Path::new("RUF013_1.py"))]
fn implicit_optional(path: &Path) -> Result<()> {
fn implicit_optional_py39(path: &Path) -> Result<()> {
let snapshot = format!(
"PY39_{}_{}",
Rule::ImplicitOptional.noqa_code(),
Expand Down Expand Up @@ -179,39 +183,6 @@ mod tests {
Ok(())
}

#[test]
fn ruff_pairwise_over_zipped() -> Result<()> {
let diagnostics = test_path(
Path::new("ruff/RUF007.py"),
&settings::Settings::for_rules(vec![Rule::PairwiseOverZipped]),
)?;
assert_messages!(diagnostics);
Ok(())
}

#[test_case(Rule::MutableDataclassDefault, Path::new("RUF008.py"))]
#[test_case(Rule::FunctionCallInDataclassDefaultArgument, Path::new("RUF009.py"))]
fn mutable_dataclass_defaults(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path(
Path::new("ruff").join(path).as_path(),
&settings::Settings::for_rule(rule_code),
)?;
assert_messages!(snapshot, diagnostics);
Ok(())
}

#[test_case(Rule::MutableClassDefault, Path::new("RUF012.py"))]
fn mutable_class_defaults(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path(
Path::new("ruff").join(path).as_path(),
&settings::Settings::for_rule(rule_code),
)?;
assert_messages!(snapshot, diagnostics);
Ok(())
}

#[test_case(Rule::InvalidPyprojectToml, Path::new("bleach"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("invalid_author"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("maturin"))]
Expand Down

0 comments on commit bdf6cb1

Please sign in to comment.