mirror of https://github.com/astral-sh/ruff
Fix auto-fix for assertEquals rename
This commit is contained in:
parent
b51a080a44
commit
a2f78ba2c7
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue