MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_sequence_length

Function test_sequence_length

tests/test_sequences_and_iterators.py:184–201  ·  view source on GitHub ↗

#2076: Exception raised by len(arg) should be propagated

()

Source from the content-addressed store, hash-verified

182
183
184def test_sequence_length():
185 """#2076: Exception raised by len(arg) should be propagated"""
186
187 class BadLen(RuntimeError):
188 pass
189
190 class SequenceLike:
191 def __getitem__(self, i):
192 return None
193
194 def __len__(self):
195 raise BadLen()
196
197 with pytest.raises(BadLen):
198 m.sequence_length(SequenceLike())
199
200 assert m.sequence_length([1, 2, 3]) == 3
201 assert m.sequence_length("hello") == 5
202
203
204def test_sequence_doc():

Callers

nothing calls this directly

Calls 1

SequenceLikeClass · 0.85

Tested by

no test coverage detected