Use `bytes` directly instead of `binary_type`
`bytes` is an alias for `str` in python2.6+
This commit is contained in:
		
							parent
							
								
									f2e35c8c4f
								
							
						
					
					
						commit
						99e31f6fb1
					
				|  | @ -402,12 +402,11 @@ def _saferepr(obj): | ||||||
|     JSON reprs. |     JSON reprs. | ||||||
| 
 | 
 | ||||||
|     """ |     """ | ||||||
|     repr = py.io.saferepr(obj) |     r = py.io.saferepr(obj) | ||||||
|     if isinstance(repr, six.text_type): |     if isinstance(r, six.text_type): | ||||||
|         t = six.text_type |         return r.replace(u"\n", u"\\n") | ||||||
|     else: |     else: | ||||||
|         t = six.binary_type |         return r.replace(b"\n", b"\\n") | ||||||
|     return repr.replace(t("\n"), t("\\n")) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| from _pytest.assertion.util import format_explanation as _format_explanation  # noqa | from _pytest.assertion.util import format_explanation as _format_explanation  # noqa | ||||||
|  | @ -446,10 +445,9 @@ def _should_repr_global_name(obj): | ||||||
| def _format_boolop(explanations, is_or): | def _format_boolop(explanations, is_or): | ||||||
|     explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")" |     explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")" | ||||||
|     if isinstance(explanation, six.text_type): |     if isinstance(explanation, six.text_type): | ||||||
|         t = six.text_type |         return explanation.replace(u"%", u"%%") | ||||||
|     else: |     else: | ||||||
|         t = six.binary_type |         return explanation.replace(b"%", b"%%") | ||||||
|     return explanation.replace(t("%"), t("%%")) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def _call_reprcompare(ops, results, expls, each_obj): | def _call_reprcompare(ops, results, expls, each_obj): | ||||||
|  |  | ||||||
|  | @ -187,9 +187,9 @@ def _diff_text(left, right, verbose=False): | ||||||
|         r = r.replace(r"\r", "\r") |         r = r.replace(r"\r", "\r") | ||||||
|         return r |         return r | ||||||
| 
 | 
 | ||||||
|     if isinstance(left, six.binary_type): |     if isinstance(left, bytes): | ||||||
|         left = escape_for_readable_diff(left) |         left = escape_for_readable_diff(left) | ||||||
|     if isinstance(right, six.binary_type): |     if isinstance(right, bytes): | ||||||
|         right = escape_for_readable_diff(right) |         right = escape_for_readable_diff(right) | ||||||
|     if not verbose: |     if not verbose: | ||||||
|         i = 0  # just in case left or right has zero length |         i = 0  # just in case left or right has zero length | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ from io import UnsupportedOperation | ||||||
| import py | import py | ||||||
| import pytest | import pytest | ||||||
| import contextlib | import contextlib | ||||||
| from six import binary_type, text_type | from six import text_type | ||||||
| from _pytest import capture | from _pytest import capture | ||||||
| from _pytest.capture import CaptureManager | from _pytest.capture import CaptureManager | ||||||
| from _pytest.main import EXIT_NOTESTSCOLLECTED | from _pytest.main import EXIT_NOTESTSCOLLECTED | ||||||
|  | @ -24,12 +24,12 @@ needsosdup = pytest.mark.xfail("not hasattr(os, 'dup')") | ||||||
| def tobytes(obj): | def tobytes(obj): | ||||||
|     if isinstance(obj, text_type): |     if isinstance(obj, text_type): | ||||||
|         obj = obj.encode("UTF-8") |         obj = obj.encode("UTF-8") | ||||||
|     assert isinstance(obj, binary_type) |     assert isinstance(obj, bytes) | ||||||
|     return obj |     return obj | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def totext(obj): | def totext(obj): | ||||||
|     if isinstance(obj, binary_type): |     if isinstance(obj, bytes): | ||||||
|         obj = text_type(obj, "UTF-8") |         obj = text_type(obj, "UTF-8") | ||||||
|     assert isinstance(obj, text_type) |     assert isinstance(obj, text_type) | ||||||
|     return obj |     return obj | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue