Skip to content

Commit

Permalink
fix bug when rewriting deprecated unittest functions
Browse files Browse the repository at this point in the history
  • Loading branch information
piazzesiNiccolo committed Sep 21, 2023
1 parent 1231861 commit cf3053a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions pyupgrade/_plugins/unittest_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def visit_Call(
)
yield ast_to_offset(node.func), func
elif (
isinstance(node.func, ast.Attribute) and
isinstance(node.func.value, ast.Name) and
node.func.value.id == 'unittest' and
node.func.attr in FUNCTION_MAPPING and
not has_starargs(node) and
not node.keywords and
len(node.args) == 1
isinstance(node.func, ast.Attribute) and
isinstance(node.func.value, ast.Name) and
node.func.value.id == 'unittest' and
node.func.attr in FUNCTION_MAPPING and
not has_starargs(node) and
not node.keywords and
len(node.args) == 1
):
func = functools.partial(
replace_name,
Expand Down
6 changes: 3 additions & 3 deletions tests/features/unittest_aliases_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@pytest.mark.parametrize(
('s',),
's',
(
pytest.param(
'class ExampleTests:\n'
Expand All @@ -16,8 +16,8 @@
id='not a deprecated alias',
),
# https://github.com/asottile/pyupgrade/issues/749#
('unittest.makeSuite(Tests, "arg")',),
('unittest.makeSuite(Tests, prefix="arg")',),
('unittest.makeSuite(Tests, "arg")'),
('unittest.makeSuite(Tests, prefix="arg")'),
),
)
def test_fix_unittest_aliases_noop(s):
Expand Down

0 comments on commit cf3053a

Please sign in to comment.