Skip to content

Commit d7a619f

Browse files
committed
TEST: fobj string assumptions need only apply to bytearrays
1 parent 28412d9 commit d7a619f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nibabel/tests/test_volumeutils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def make_array(n, bytes):
103103
# Read back from file
104104
fobj_r = opener(fname, 'rb')
105105
try:
106-
contents1 = fobj_r.read()
106+
contents1 = bytearray(4 * n)
107+
fobj_r.readinto(contents1)
107108
# Second element is 1
108109
assert_false(contents1[0:8] == b'\x00' * 8)
109110
out_arr = make_array(n, contents1)
@@ -114,7 +115,8 @@ def make_array(n, bytes):
114115
assert_equal(contents1[:8], b'\x00' * 8)
115116
# Reread, to get unmodified contents
116117
fobj_r.seek(0)
117-
contents2 = fobj_r.read()
118+
contents2 = bytearray(4 * n)
119+
fobj_r.readinto(contents2)
118120
out_arr2 = make_array(n, contents2)
119121
assert_array_equal(in_arr, out_arr2)
120122
assert_equal(out_arr[1], 0)

0 commit comments

Comments
 (0)