From e7ed45a5d4d268e253e5836cdb69fac2fd8802b9 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Tue, 19 Aug 2014 20:50:25 +0200 Subject: [PATCH] Explain why this is important --- _pytest/assertion/rewrite.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index 772f3ac03..6cb5ee96c 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -327,6 +327,13 @@ def rewrite_asserts(mod): def _saferepr(obj): + """Get a safe repr of an object for assertion error messages + + The assertion formatting (util.format_explanation()) requires + newlines to be escaped since they are a special character for it. + But py.io.saferepr allows newlines, so we need to escape them + here. + """ repr = py.io.saferepr(obj) if py.builtin._istext(repr): t = py.builtin.text