1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/4d292f7031ab/ Changeset: 4d292f7031ab User: flub Date: 2014-10-28 13:26:21+00:00 Summary: Merged in tomviner/pytest/format_boolop_percent6 (pull request #231)
fix for issue #615: _format_boolop must escape % Affected #: 3 files diff -r fb9d798eba06ab252e7a00c39be588d3d9dd1fb2 -r 4d292f7031ab164eca0039c1c439393717987a6a AUTHORS --- a/AUTHORS +++ b/AUTHORS @@ -45,3 +45,4 @@ Trevor Bekolay David Mohr Nicolas Delaby +Tom Viner diff -r fb9d798eba06ab252e7a00c39be588d3d9dd1fb2 -r 4d292f7031ab164eca0039c1c439393717987a6a _pytest/assertion/rewrite.py --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -382,7 +382,12 @@ return not hasattr(obj, "__name__") and not py.builtin.callable(obj) def _format_boolop(explanations, is_or): - return "(" + (is_or and " or " or " and ").join(explanations) + ")" + explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")" + if py.builtin._istext(explanation): + t = py.builtin.text + else: + t = py.builtin.bytes + return explanation.replace(t('%'), t('%%')) def _call_reprcompare(ops, results, expls, each_obj): for i, res, expl in zip(range(len(ops)), results, expls): diff -r fb9d798eba06ab252e7a00c39be588d3d9dd1fb2 -r 4d292f7031ab164eca0039c1c439393717987a6a testing/test_assertrewrite.py --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -270,15 +270,13 @@ assert not 5 % 4 assert getmsg(f) == "assert not (5 % 4)" - @pytest.mark.xfail(reason='unfixed') - def test_and_or_percent(self): - # issue 615 - ValueError on compound assert with percent + def test_boolop_percent(self): def f(): - assert 3 % 2 or False - assert getmsg(f) == "assert (3 % 2) or False" + assert 3 % 2 and False + assert getmsg(f) == "assert ((3 % 2) and False)" def f(): - assert True and 7 % 3 - assert getmsg(f) == "assert True and (7 % 3)" + assert False or 4 % 2 + assert getmsg(f) == "assert (False or (4 % 2))" def test_call(self): def g(a=42, *args, **kwargs): Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit