Escape newlines in repr for assertion rewriting
The assertion formatting mini-language depends on newlines being escaped. Unfortunately if the repr of an object contained newlines the rewriting module did not escape those, which is now fixed. Fixes issue453.
This commit is contained in:
@@ -313,6 +313,17 @@ class TestAssertionRewrite:
|
||||
assert "%test" == "test"
|
||||
assert getmsg(f).startswith("assert '%test' == 'test'")
|
||||
|
||||
def test_custom_repr(self):
|
||||
def f():
|
||||
class Foo(object):
|
||||
a = 1
|
||||
|
||||
def __repr__(self):
|
||||
return "\n{ \n~ \n}"
|
||||
f = Foo()
|
||||
assert 0 == f.a
|
||||
assert r"where 1 = \n{ \n~ \n}.a" in util._format_lines([getmsg(f)])[0]
|
||||
|
||||
|
||||
class TestRewriteOnImport:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user