escape '%' in specialized comparison explanations (fixes #63)
This commit is contained in:
parent
a70293fdb7
commit
2c4964d290
|
@ -1,6 +1,7 @@
|
||||||
Changes between 2.1.0 and 2.1.1.DEV
|
Changes between 2.1.0 and 2.1.1.DEV
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
|
- fix assertion rewriting on inserts involving strings containing '%'
|
||||||
- fix assertion rewriting on calls with a ** arg
|
- fix assertion rewriting on calls with a ** arg
|
||||||
- don't cache rewritten modules if bytecode generation is disabled
|
- don't cache rewritten modules if bytecode generation is disabled
|
||||||
- fix assertion rewriting in read-only directories
|
- fix assertion rewriting in read-only directories
|
||||||
|
|
|
@ -45,7 +45,13 @@ def pytest_configure(config):
|
||||||
config=config, op=op, left=left, right=right)
|
config=config, op=op, left=left, right=right)
|
||||||
for new_expl in hook_result:
|
for new_expl in hook_result:
|
||||||
if new_expl:
|
if new_expl:
|
||||||
return '\n~'.join(new_expl)
|
res = '\n~'.join(new_expl)
|
||||||
|
if mode == "rewrite":
|
||||||
|
# The result will be fed back a python % formatting
|
||||||
|
# operation, which will fail if there are extraneous
|
||||||
|
# '%'s in the string. Escape them here.
|
||||||
|
res = res.replace("%", "%%")
|
||||||
|
return res
|
||||||
m = monkeypatch()
|
m = monkeypatch()
|
||||||
config._cleanup.append(m.undo)
|
config._cleanup.append(m.undo)
|
||||||
m.setattr(py.builtin.builtins, 'AssertionError',
|
m.setattr(py.builtin.builtins, 'AssertionError',
|
||||||
|
|
|
@ -275,6 +275,11 @@ class TestAssertionRewrite:
|
||||||
assert myany(A() < 0)
|
assert myany(A() < 0)
|
||||||
assert "<MY42 object> < 0" in getmsg(f)
|
assert "<MY42 object> < 0" in getmsg(f)
|
||||||
|
|
||||||
|
def test_formatchar(self):
|
||||||
|
def f():
|
||||||
|
assert "%test" == "test"
|
||||||
|
assert getmsg(f).startswith("assert '%test' == 'test'")
|
||||||
|
|
||||||
|
|
||||||
class TestRewriteOnImport:
|
class TestRewriteOnImport:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue