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

assertion rewriting should report errors when passing tuples to assertions #1562

Closed
RonnyPfannschmidt opened this issue May 19, 2016 · 5 comments
Labels
good first issue easy issue that is friendly to new contributor status: help wanted developers would like help from experts on this topic type: enhancement new feature or API change, should be merged into features branch type: feature-branch new feature or API change, should be merged into features branch
Milestone

Comments

@RonnyPfannschmidt
Copy link
Member

in a downstream project we suffered some false passes due to a new programmer using code like

assert(condition, message) which is always true and certainly wasn't the intention

@RonnyPfannschmidt RonnyPfannschmidt added type: enhancement new feature or API change, should be merged into features branch status: help wanted developers would like help from experts on this topic good first issue easy issue that is friendly to new contributor type: feature-branch new feature or API change, should be merged into features branch sprint-candidate labels May 19, 2016
@Akasurde
Copy link
Contributor

@RonnyPfannschmidt I would love to work on this. Could you please explain more about this issue?

@RonnyPfannschmidt
Copy link
Member Author

@Akasurde the idea is, that when the ast rewriter sees a Assert node whose assertion is a tuple, it should issue a pytest-warning

the problem is that python has an equivalence of assert (False , 'foo') and ohjoy = (False , 'foo'); assert ohjoy

so we can take it for sure, that the test-writer meant to write assert False , 'foo' however we should not correct and/or hide that, instead just inform them

@The-Compiler
Copy link
Member

Would it be possible to only issue the warning if it's a tuple literal? I think if assert some_tuple would show a warning that'd be quite bad.

@RonnyPfannschmidt
Copy link
Member Author

@The-Compiler thats how i meant it, i just used the example to show what python does

nicoddemus added a commit that referenced this issue Jun 26, 2016
Add warning for assertions on tuples #1562
@nicoddemus
Copy link
Member

Fixed in #1675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor status: help wanted developers would like help from experts on this topic type: enhancement new feature or API change, should be merged into features branch type: feature-branch new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

4 participants