summaryrefslogtreecommitdiff
path: root/numpy/f2py
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/f2py
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/f2py')
-rw-r--r--numpy/f2py/tests/test_return_character.py19
-rw-r--r--numpy/f2py/tests/util.py2
2 files changed, 10 insertions, 11 deletions
diff --git a/numpy/f2py/tests/test_return_character.py b/numpy/f2py/tests/test_return_character.py
index e3e2b0d7e..7704e7d28 100644
--- a/numpy/f2py/tests/test_return_character.py
+++ b/numpy/f2py/tests/test_return_character.py
@@ -1,7 +1,6 @@
from __future__ import division, absolute_import, print_function
from numpy import array
-from numpy.compat import asbytes
from numpy.testing import run_module_suite, assert_, dec
import util
@@ -11,22 +10,22 @@ class TestReturnCharacter(util.F2PyTest):
def check_function(self, t):
tname = t.__doc__.split()[0]
if tname in ['t0', 't1', 's0', 's1']:
- assert_(t(23) == asbytes('2'))
+ assert_(t(23) == b'2')
r = t('ab')
- assert_(r == asbytes('a'), repr(r))
+ assert_(r == b'a', repr(r))
r = t(array('ab'))
- assert_(r == asbytes('a'), repr(r))
+ assert_(r == b'a', repr(r))
r = t(array(77, 'u1'))
- assert_(r == asbytes('M'), repr(r))
+ assert_(r == b'M', repr(r))
#assert_(_raises(ValueError, t, array([77,87])))
#assert_(_raises(ValueError, t, array(77)))
elif tname in ['ts', 'ss']:
- assert_(t(23) == asbytes('23 '), repr(t(23)))
- assert_(t('123456789abcdef') == asbytes('123456789a'))
+ assert_(t(23) == b'23 ', repr(t(23)))
+ assert_(t('123456789abcdef') == b'123456789a')
elif tname in ['t5', 's5']:
- assert_(t(23) == asbytes('23 '), repr(t(23)))
- assert_(t('ab') == asbytes('ab '), repr(t('ab')))
- assert_(t('123456789abcdef') == asbytes('12345'))
+ assert_(t(23) == b'23 ', repr(t(23)))
+ assert_(t('ab') == b'ab ', repr(t('ab')))
+ assert_(t('123456789abcdef') == b'12345')
else:
raise NotImplementedError
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
index 0c9e91568..fe608d898 100644
--- a/numpy/f2py/tests/util.py
+++ b/numpy/f2py/tests/util.py
@@ -213,7 +213,7 @@ sys.exit(99)
stderr=subprocess.STDOUT)
out, err = p.communicate()
- m = re.search(asbytes(r'COMPILERS:(\d+),(\d+),(\d+)'), out)
+ m = re.search(br'COMPILERS:(\d+),(\d+),(\d+)', out)
if m:
_compiler_status = (bool(int(m.group(1))), bool(int(m.group(2))),
bool(int(m.group(3))))