diff --git a/resources/test/fixtures/U005.py b/resources/test/fixtures/U005.py index 779eb5689c..5812f93e31 100644 --- a/resources/test/fixtures/U005.py +++ b/resources/test/fixtures/U005.py @@ -1,3 +1,8 @@ -self.assertEquals (1, 2) -self.assertEquals(1, 2) -self.assertEqual(3, 4) +import unittest + + +class Suite(unittest.TestCase): + def test(self) -> None: + self.assertEquals (1, 2) + self.assertEquals(1, 2) + self.assertEqual(3, 4) diff --git a/src/plugins/assert_equals.rs b/src/plugins/assert_equals.rs index a6720c4b50..39dd0bdb66 100644 --- a/src/plugins/assert_equals.rs +++ b/src/plugins/assert_equals.rs @@ -9,12 +9,9 @@ pub fn assert_equals(checker: &mut Checker, expr: &Expr) { if let Some(mut check) = checks::check_assert_equals(expr) { if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) { check.amend(Fix { - content: "assertEqual".to_string(), - location: Location::new(expr.location.row(), expr.location.column() + 1), - end_location: Location::new( - expr.location.row(), - expr.location.column() + 1 + "assertEquals".len(), - ), + content: "self.assertEqual".to_string(), + location: Location::new(expr.location.row(), expr.location.column()), + end_location: Location::new(expr.end_location.row(), expr.end_location.column()), applied: false, }); } diff --git a/src/snapshots/ruff__linter__tests__u005.snap b/src/snapshots/ruff__linter__tests__u005.snap index b2169811ab..cace578e1b 100644 --- a/src/snapshots/ruff__linter__tests__u005.snap +++ b/src/snapshots/ruff__linter__tests__u005.snap @@ -4,34 +4,34 @@ expression: checks --- - kind: NoAssertEquals location: - row: 1 - column: 1 + row: 6 + column: 9 end_location: - row: 1 - column: 18 + row: 6 + column: 26 fix: - content: assertEqual + content: self.assertEqual location: - row: 1 - column: 2 + row: 6 + column: 9 end_location: - row: 1 - column: 14 + row: 6 + column: 26 applied: false - kind: NoAssertEquals location: - row: 2 - column: 1 + row: 7 + column: 9 end_location: - row: 2 - column: 18 + row: 7 + column: 26 fix: - content: assertEqual + content: self.assertEqual location: - row: 2 - column: 2 + row: 7 + column: 9 end_location: - row: 2 - column: 14 + row: 7 + column: 26 applied: false