diff --git a/resources/test/fixtures/flake8_print/T100.py b/resources/test/fixtures/flake8_debugger/T100.py similarity index 99% rename from resources/test/fixtures/flake8_print/T100.py rename to resources/test/fixtures/flake8_debugger/T100.py index 5e386dfe2a..d0f173db57 100644 --- a/resources/test/fixtures/flake8_print/T100.py +++ b/resources/test/fixtures/flake8_debugger/T100.py @@ -1,6 +1,5 @@ breakpoint() - import pdb import builtins from builtins import breakpoint @@ -9,7 +8,6 @@ from celery.contrib.rdb import set_trace from celery.contrib import rdb import celery.contrib.rdb - breakpoint() st() set_trace() diff --git a/src/flake8_debugger/mod.rs b/src/flake8_debugger/mod.rs index 62a8881c0e..1f521d5e8a 100644 --- a/src/flake8_debugger/mod.rs +++ b/src/flake8_debugger/mod.rs @@ -1,2 +1,29 @@ pub mod checks; pub mod types; + +#[cfg(test)] +mod tests { + use std::convert::AsRef; + use std::path::Path; + + use anyhow::Result; + use test_case::test_case; + + use crate::checks::CheckCode; + use crate::linter::test_path; + use crate::settings; + + #[test_case(CheckCode::T100, Path::new("T100.py"); "T100")] + fn checks(check_code: CheckCode, path: &Path) -> Result<()> { + let snapshot = format!("{}_{}", check_code.as_ref(), path.to_string_lossy()); + let mut checks = test_path( + Path::new("./resources/test/fixtures/flake8_debugger") + .join(path) + .as_path(), + &settings::Settings::for_rule(check_code), + )?; + checks.sort_by_key(|check| check.location); + insta::assert_yaml_snapshot!(snapshot, checks); + Ok(()) + } +} diff --git a/src/flake8_print/snapshots/ruff__flake8_print__tests__T100_T100.py.snap b/src/flake8_debugger/snapshots/ruff__flake8_debugger__tests__T100_T100.py.snap similarity index 88% rename from src/flake8_print/snapshots/ruff__flake8_print__tests__T100_T100.py.snap rename to src/flake8_debugger/snapshots/ruff__flake8_debugger__tests__T100_T100.py.snap index fd33c78b4c..9944cd257d 100644 --- a/src/flake8_print/snapshots/ruff__flake8_print__tests__T100_T100.py.snap +++ b/src/flake8_debugger/snapshots/ruff__flake8_debugger__tests__T100_T100.py.snap @@ -1,5 +1,5 @@ --- -source: src/flake8_print/mod.rs +source: src/flake8_debugger/mod.rs expression: checks --- - kind: @@ -16,80 +16,80 @@ expression: checks Debugger: Import: pdb location: - row: 4 + row: 3 column: 0 end_location: - row: 4 + row: 3 column: 10 fix: ~ - kind: Debugger: Import: builtins.breakpoint location: - row: 6 + row: 5 column: 0 end_location: - row: 6 + row: 5 column: 31 fix: ~ - kind: Debugger: Import: pdb.set_trace location: - row: 7 + row: 6 column: 0 end_location: - row: 7 + row: 6 column: 31 fix: ~ - kind: Debugger: Import: celery.contrib.rdb.set_trace location: - row: 8 + row: 7 column: 0 end_location: - row: 8 + row: 7 column: 40 fix: ~ - kind: Debugger: Import: celery.contrib.rdb location: - row: 10 + row: 9 column: 0 end_location: - row: 10 + row: 9 column: 25 fix: ~ - kind: Debugger: Call: breakpoint location: - row: 13 + row: 11 column: 0 end_location: - row: 13 + row: 11 column: 12 fix: ~ - kind: Debugger: Call: set_trace location: - row: 14 + row: 12 column: 0 end_location: - row: 14 + row: 12 column: 4 fix: ~ - kind: Debugger: Call: set_trace location: - row: 15 + row: 13 column: 0 end_location: - row: 15 + row: 13 column: 11 fix: ~ diff --git a/src/flake8_print/mod.rs b/src/flake8_print/mod.rs index 02b729fdaf..8a602d25cd 100644 --- a/src/flake8_print/mod.rs +++ b/src/flake8_print/mod.rs @@ -13,7 +13,6 @@ mod tests { use crate::linter::test_path; use crate::settings; - #[test_case(CheckCode::T100, Path::new("T100.py"); "T100")] #[test_case(CheckCode::T201, Path::new("T201.py"); "T201")] #[test_case(CheckCode::T203, Path::new("T203.py"); "T203")] fn checks(check_code: CheckCode, path: &Path) -> Result<()> {