#2076: Exception raised by len(arg) should be propagated
()
| 182 | |
| 183 | |
| 184 | def 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 | |
| 204 | def test_sequence_doc(): |
nothing calls this directly
no test coverage detected