Skip to content

Commit 1b180c5

Browse files
committed
Test ensure_bytes raises on an object array
Add a test to check that `ensure_bytes` raises a `TypeError` when an `object` array is provided as an argument.
1 parent 7e5297b commit 1b180c5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

numcodecs/tests/test_compat.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ def test_ensure_contiguous_ndarray_shares_memory():
5151
assert np.shares_memory(a, memoryview(buf))
5252

5353

54+
def test_ensure_bytes_invalid_inputs():
55+
56+
# object array not allowed
57+
a = np.array([u'Xin chào thế giới'], dtype=object)
58+
for e in [a, memoryview(a)]:
59+
with pytest.raises(TypeError):
60+
ensure_bytes(e)
61+
62+
5463
def test_ensure_contiguous_ndarray_invalid_inputs():
5564

5665
# object array not allowed

0 commit comments

Comments
 (0)