summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_format.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-03-25 10:11:43 +0000
committerEric Wieser <wieser.eric@gmail.com>2017-03-25 10:36:28 +0000
commitb87fca27261f79be20ab06a222ed2330d60d9f2c (patch)
tree00907ad5fffa7d13f99b1cf60398c624063f807e /numpy/lib/tests/test_format.py
parenta2c4d3230d58a5c4569ab2c7f13bdf9499b71dd4 (diff)
downloadnumpy-b87fca27261f79be20ab06a222ed2330d60d9f2c.tar.gz
MAINT: Remove asbytes where a b prefix would suffice
Since we only need to support python 2, we can remove any case where we just pass a single string literal and use the b prefix instead. What we can't do is transform asbytes("tests %d" % num), because %-formatting fails on bytes in python 3.x < 3.5.
Diffstat (limited to 'numpy/lib/tests/test_format.py')
-rw-r--r--numpy/lib/tests/test_format.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index 7cc72e775..77ac5942a 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -284,7 +284,7 @@ import warnings
from io import BytesIO
import numpy as np
-from numpy.compat import asbytes, asbytes_nested, sixu
+from numpy.compat import asbytes_nested, sixu
from numpy.testing import (
run_module_suite, assert_, assert_array_equal, assert_raises, raises,
dec, SkipTest
@@ -546,7 +546,7 @@ def test_pickle_python2_python3():
xrange = __builtin__.xrange
expected = np.array([None, xrange, sixu('\u512a\u826f'),
- asbytes('\xe4\xb8\x8d\xe8\x89\xaf')],
+ b'\xe4\xb8\x8d\xe8\x89\xaf'],
dtype=object)
for fname in ['py2-objarr.npy', 'py2-objarr.npz',
@@ -778,11 +778,11 @@ def test_bad_header():
# header of length less than 2 should fail
s = BytesIO()
assert_raises(ValueError, format.read_array_header_1_0, s)
- s = BytesIO(asbytes('1'))
+ s = BytesIO(b'1')
assert_raises(ValueError, format.read_array_header_1_0, s)
# header shorter than indicated size should fail
- s = BytesIO(asbytes('\x01\x00'))
+ s = BytesIO(b'\x01\x00')
assert_raises(ValueError, format.read_array_header_1_0, s)
# headers without the exact keys required should fail