Fix tests on Python 2 -- attempt 3

parent 5e15c4e3
...@@ -1089,20 +1089,25 @@ def optimised_index_of_slice(int[:,:,:] arr, int x, int y, int z): ...@@ -1089,20 +1089,25 @@ def optimised_index_of_slice(int[:,:,:] arr, int x, int y, int z):
def test_assign_from_byteslike(byteslike): def test_assign_from_byteslike(byteslike):
# Once http://python3statement.org is accepted, should be just
# >>> test_assign_from_byteslike(bytes(b'hello'))
# b'hello'
# ...
""" """
>>> test_assign_from_byteslike(bytes(b'hello')) == b'hello' >>> print(test_assign_from_byteslike(bytes(b'hello')).decode())
True hello
>>> test_assign_from_byteslike(bytearray(b'howdy')) == b'howdy' >>> print(test_assign_from_byteslike(bytearray(b'howdy')).decode())
True howdy
""" """
# fails on Python 2.7- with # fails on Python 2.7- with
# TypeError: an integer is required # TypeError: an integer is required
# >>> test_assign_from_byteslike(pyarray.array('B', b'aloha')) == b'aloha' # >>> print(test_assign_from_byteslike(pyarray.array('B', b'aloha')).decode())
# True # aloha
# fails on Python 2.6- with # fails on Python 2.6- with
# NameError: name 'memoryview' is not defined # NameError: name 'memoryview' is not defined
# >>> test_assign_from_byteslike(memoryview(b'bye!!')) == b'bye!!' # >>> print(test_assign_from_byteslike(memoryview(b'bye!!')).decode())
# True # bye!!
def assign(m): def assign(m):
m[:] = byteslike m[:] = byteslike
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment