Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
missing evaluated value in report when asserting a boolean attribute (using --assert=rewrite) #1503
First of all, thank you for the amazing work you've done on pytest! It is really cool!
Provides the following output (using with ---assert=rewrite):
And if run with ---assert=reinterp:
This is caused by the _collapse_false function, which aims to trim away trivial explanations.
For example this test:
def test_false_value(): x = 0 assert bool(x)
Full explanation, with
def test_false_value(): x = 0 > assert bool(x) E assert False E + where False = bool(0)
Trimmed explanation, with
def test_false_value(): x = 0 > assert bool(x) E assert bool(0)
I'm having trouble recreating an example where useful information is trimmed away.
Hi tomviner, Thanks for your reply. I wasn't aware of such behaviour and in my case I wasn't sure if my asserted value was a boolean or not. In fact if you take the following test:
The output isn't telling me if mo.a is False or if it's anything else that evalues to False (0 for instance). It turns out that the output is different if it is 0 but without knowing this, you can't tell...