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

Comments

Projects
None yet
4 participants
@RonnyPfannschmidt
Member

RonnyPfannschmidt commented May 19, 2016

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

@Akasurde

This comment has been minimized.

Contributor

Akasurde commented May 27, 2016

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

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented May 28, 2016

@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

This comment has been minimized.

Member

The-Compiler commented May 28, 2016

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

This comment has been minimized.

Member

RonnyPfannschmidt commented May 28, 2016

@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

Merge pull request #1675 from kvas-it/issue-1562
Add warning for assertions on tuples #1562
@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Jun 26, 2016

Fixed in #1675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment