[Pytest-commit] Issue #615: ValueError on compound assert with percent (hpk42/pytest)
Tom V
issues-reply at bitbucket.org
Sun Oct 12 23:17:42 CEST 2014
New issue 615: ValueError on compound assert with percent
https://bitbucket.org/hpk42/pytest/issue/615/valueerror-on-compound-assert-with-percent
Tom V:
Assertions like `assert 1 % 1 or False` or ``assert True and 1 % 1`` fail with: `ValueError: unsupported format character ')' (0x29) at index 7`.
This behaviour is not seen with `py.test --assert=reinterp` or `--assert=plain`.
Example:
def test_high_odd():
n = 20
high = n > 10
assert high and (n % 2 > 0)
def test_simple_percent_error():
assert 1 % 1 and False
# no ValueError
def test_var_high_odd():
n = 20
high = n > 10
odd = n % 2 > 0
assert high and odd
$ py.test percent_error.py
=== test session starts ===
platform linux2 -- Python 2.7.6 -- py-1.4.25 -- pytest-2.6.4.dev1
collected 3 items
percent_error.py FFF
=== FAILURES ===
___ test_high_odd ___
def test_high_odd():
n = 20
high = n > 10
> assert high and (n % 2 > 0)
E ValueError: unsupported format character ')' (0x29) at index 17
percent_error.py:5: ValueError
___ test_simple_percent_error ___
def test_simple_percent_error():
> assert 1 % 1 and False
E ValueError: unsupported format character ')' (0x29) at index 7
percent_error.py:8: ValueError
___ test_var_high_odd ___
def test_var_high_odd():
n = 20
high = n > 10
odd = n % 2 > 0
> assert high and odd
E assert (True and False)
percent_error.py:15: AssertionError
=== 3 failed in 0.01 seconds ===
Happy to have a go at writing a failing test in `TestAssertionRewrite`.
More information about the pytest-commit
mailing list