-
Notifications
You must be signed in to change notification settings - Fork 107
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
Bugfix: Verify the element in item_context.args is of type ast.Name #166
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```with assertRaises(Exception):``` is basically a "catch 'em all" assert that casts far too broad of a net when it comes to detecting failures in code being tested. Assertions should be testing specific failure cases, not "did Python throw /any/ type of error?", and so the context manager form, or the assertRaisesRegex form are far better to use.
Attempts to ensure we're only looking at Name type objects in the item_context.args, since apparently this code is still matching other objects that don't have an id attr.
cricalix
changed the title
Bugfix: Fix #164 again by adding another conditional
Bugfix: Verify the element in item_context.args is of type ast.Name
Apr 1, 2021
cooperlees
approved these changes
Apr 1, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ast is fun. Ok, some more edge cases covered. Hopefully this gets majority.
Thank you @cricalix and @cooperlees , this diff (v21.4.3) solves the error on my end. |
Thanks, sorry for causing it. We needed to do better testing here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The sample case that broke the assumptions in the code was doing a module.Error type assertRaises. In this case, item_context.args[0] is now a Call object (without an id attr), not a Name object. So, qualify the conditions even more, and add a test case for the sample provided by @DStape.
Should address #164