1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/63ee1c59835a/ Changeset: 63ee1c59835a User: hpk42 Date: 2014-10-07 07:06:47+00:00 Summary: Merged in bubenkoff/pytest/test_for_issue_604 (pull request #220)
Escape % character in the assertion message Affected #: 3 files diff -r fb399a582553ac8180e5706ad0e34149da85436e -r 63ee1c59835ab6b44c868a410d3d40f9bcebb843 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,8 @@ at the beginning of strings and even that is deprecated. Use "not" instead. This should allow to pick parametrized tests where "-" appeared in the parameter. +- fix issue604: Escape % character in the assertion message. + 2.6.3 ----------- diff -r fb399a582553ac8180e5706ad0e34149da85436e -r 63ee1c59835ab6b44c868a410d3d40f9bcebb843 _pytest/assertion/rewrite.py --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -373,7 +373,7 @@ t = py.builtin.text else: t = py.builtin.bytes - s = s.replace(t("\n"), t("\n~")) + s = s.replace(t("\n"), t("\n~")).replace(t("%"), t("%%")) if is_repr: s = s.replace(t("\\n"), t("\n~")) return s diff -r fb399a582553ac8180e5706ad0e34149da85436e -r 63ee1c59835ab6b44c868a410d3d40f9bcebb843 testing/test_assertrewrite.py --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -172,6 +172,18 @@ "*assert 1 == 2*", ]) + def test_assertion_message_escape(self, testdir): + testdir.makepyfile(""" + def test_foo(): + assert 1 == 2, 'To be escaped: %' + """) + result = testdir.runpytest() + assert result.ret == 1 + result.stdout.fnmatch_lines([ + "*AssertionError: To be escaped: %", + "*assert 1 == 2", + ]) + def test_boolop(self): def f(): f = g = False 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