From c9480c5b8bc2ef68df64771f0e6dc75832db764e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Sep 2015 17:02:19 -0300 Subject: [PATCH] Move imports outside _escape_bytes as suggested in review --- _pytest/python.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index da41bf8e9..4dc3dd7ad 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1041,6 +1041,8 @@ class Metafunc(FuncargnamesCompatAttr): if _PY3: + import codecs + def _escape_bytes(val): """ If val is pure ascii, returns it as a str(), otherwise escapes @@ -1055,7 +1057,6 @@ if _PY3: """ if val: # source: http://goo.gl/bGsnwC - import codecs encoded_bytes, _ = codecs.escape_encode(val) return encoded_bytes.decode('ascii') else: @@ -1064,7 +1065,7 @@ if _PY3: else: def _escape_bytes(val): """ - In py2 bytes and str are the same, so return it unchanged if it + In py2 bytes and str are the same type, so return it unchanged if it is a full ascii string, otherwise escape it into its binary form. """ try: