escape the % operator in string formatting

This commit is contained in:
Benjamin Peterson 2012-05-03 13:49:30 -04:00
parent 64c7c1be15
commit b4588f1798
3 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
Changese between 2.2.3 and ...
-----------------------------------
- fix error message for rewritten assertions involving the % operator
- fix issue 126: correctly match all invalid xml characters for junitxml
binary escape
- fix issue with unittest: now @unittest.expectedFailure markers should

View File

@ -297,7 +297,7 @@ binop_map = {
ast.Mult : "*",
ast.Div : "/",
ast.FloorDiv : "//",
ast.Mod : "%",
ast.Mod : "%%", # escaped for string formatting
ast.Eq : "==",
ast.NotEq : "!=",
ast.Lt : "<",

View File

@ -195,6 +195,10 @@ class TestAssertionRewrite:
y = -1
assert x + y
assert getmsg(f) == "assert (1 + -1)"
def f():
x = range(10)
assert not 5 % 4
assert getmsg(f) == "assert not (5 % 4)"
def test_call(self):
def g(a=42, *args, **kwargs):