MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_raises_exception_looks_iterable

Method test_raises_exception_looks_iterable

testing/python/raises.py:244–259  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

242 int("asdf")
243
244 def test_raises_exception_looks_iterable(self):
245 class Meta(type):
246 def __getitem__(self, item):
247 return 1 / 0
248
249 def __len__(self):
250 return 1
251
252 class ClassLooksIterableException(Exception, metaclass=Meta):
253 pass
254
255 with pytest.raises(
256 Failed,
257 match=r"DID NOT RAISE <class 'raises(\..*)*ClassLooksIterableException'>",
258 ):
259 pytest.raises(ClassLooksIterableException, lambda: None)
260
261 def test_raises_with_raising_dunder_class(self) -> None:
262 """Test current behavior with regard to exceptions via __class__ (#4284)."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected