File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed
Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -402,12 +402,11 @@ def _saferepr(obj):
402402 JSON reprs.
403403
404404 """
405- repr = py .io .saferepr (obj )
406- if isinstance (repr , six .text_type ):
407- t = six . text_type
405+ r = py .io .saferepr (obj )
406+ if isinstance (r , six .text_type ):
407+ return r . replace ( u" \n " , u" \\ n" )
408408 else :
409- t = six .binary_type
410- return repr .replace (t ("\n " ), t ("\\ n" ))
409+ return r .replace (b"\n " , b"\\ n" )
411410
412411
413412from _pytest .assertion .util import format_explanation as _format_explanation # noqa
@@ -446,10 +445,9 @@ def _should_repr_global_name(obj):
446445def _format_boolop (explanations , is_or ):
447446 explanation = "(" + (is_or and " or " or " and " ).join (explanations ) + ")"
448447 if isinstance (explanation , six .text_type ):
449- t = six . text_type
448+ return explanation . replace ( u"%" , u"%%" )
450449 else :
451- t = six .binary_type
452- return explanation .replace (t ("%" ), t ("%%" ))
450+ return explanation .replace (b"%" , b"%%" )
453451
454452
455453def _call_reprcompare (ops , results , expls , each_obj ):
Original file line number Diff line number Diff line change @@ -187,9 +187,9 @@ def escape_for_readable_diff(binary_text):
187187 r = r .replace (r"\r" , "\r " )
188188 return r
189189
190- if isinstance (left , six . binary_type ):
190+ if isinstance (left , bytes ):
191191 left = escape_for_readable_diff (left )
192- if isinstance (right , six . binary_type ):
192+ if isinstance (right , bytes ):
193193 right = escape_for_readable_diff (right )
194194 if not verbose :
195195 i = 0 # just in case left or right has zero length
Original file line number Diff line number Diff line change 1212import py
1313import pytest
1414import contextlib
15- from six import binary_type , text_type
15+ from six import text_type
1616from _pytest import capture
1717from _pytest .capture import CaptureManager
1818from _pytest .main import EXIT_NOTESTSCOLLECTED
2424def tobytes (obj ):
2525 if isinstance (obj , text_type ):
2626 obj = obj .encode ("UTF-8" )
27- assert isinstance (obj , binary_type )
27+ assert isinstance (obj , bytes )
2828 return obj
2929
3030
3131def totext (obj ):
32- if isinstance (obj , binary_type ):
32+ if isinstance (obj , bytes ):
3333 obj = text_type (obj , "UTF-8" )
3434 assert isinstance (obj , text_type )
3535 return obj
You can’t perform that action at this time.
0 commit comments