Skip to content

Commit

Permalink
Add subtests to demonstrate processing Python buffer protocol objects…
Browse files Browse the repository at this point in the history
… with step > 1
  • Loading branch information
Marc Chiesa committed Aug 4, 2020
1 parent ddc4704 commit 1fcc435
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_stl_binders.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def test_vector_buffer():
mv[2] = '\x06'
assert v[2] == 6

mv = memoryview(b)
v = m.VectorUChar(mv[::2])
assert v[1] == 3

with pytest.raises(RuntimeError) as excinfo:
m.create_undeclstruct() # Undeclared struct contents, no buffer interface
assert "NumPy type info missing for " in str(excinfo.value)
Expand Down Expand Up @@ -118,6 +122,10 @@ def test_vector_buffer_numpy():
('y', 'float64'), ('z', 'bool')], align=True)))
assert len(v) == 3

b = np.array([1, 2, 3, 4], dtype=np.uint8)
v = m.VectorUChar(b[::2])
assert v[1] == 3


def test_vector_bool():
import pybind11_cross_module_tests as cm
Expand Down

0 comments on commit 1fcc435

Please sign in to comment.