Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug when rewriting deprecated unittest functions #891

Merged

Conversation

piazzesiNiccolo
Copy link
Contributor

Closes #749.

I saw that #759 was closed without actually fixing the issue.

Comment on lines 59 to 62
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't touch unrelated code to imbue your style on it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, left formatter settings on, sorry

Comment on lines 19 to 20
('unittest.makeSuite(Tests, "arg")',),
('unittest.makeSuite(Tests, prefix="arg")',),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't have to be 1-tuples -- can just be strings

Comment on lines 19 to 20
('unittest.makeSuite(Tests, "arg")'),
('unittest.makeSuite(Tests, prefix="arg")'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these parens do nothing

(
pytest.param(
'class ExampleTests:\n'
' def test_something(self):\n'
' self.assertEqual(1, 1)\n',
id='not a deprecated alias',
),
# https://github.com/asottile/pyupgrade/issues/749#
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this link is important put it in the pytest id -- if it's not remove it -- also it contains a typo

@asottile
Copy link
Owner

the commit message is kinda unclear here -- it probably should be something closer to "prevent rewriting unittest module functions with additional arguments" -- or something like it

@piazzesiNiccolo
Copy link
Contributor Author

just mistakenly copied an old git command when changing commit message, fixing this

Copy link
Owner

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit 443797a into asottile:main Sep 21, 2023
7 checks passed
@piazzesiNiccolo piazzesiNiccolo deleted the unit_test_deprecated_aliases_bug branch September 21, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unittest.makeSuite() with prefix incorrectly rewritten
2 participants