MCPcopy
hub / github.com/pytest-dev/pytest / RaisingOnStrRepr

Class RaisingOnStrRepr

testing/io/test_saferepr.py:72–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 """Test saferepr() with BaseExceptions, which includes pytest outcomes."""
71
72 class RaisingOnStrRepr(BaseException):
73 def __init__(self, exc_types):
74 self.exc_types = exc_types
75
76 def raise_exc(self, *args):
77 try:
78 self.exc_type = self.exc_types.pop(0)
79 except IndexError:
80 pass
81 if hasattr(self.exc_type, "__call__"):
82 raise self.exc_type(*args)
83 raise self.exc_type
84
85 def __str__(self): # noqa: PLE0307
86 self.raise_exc("__str__")
87
88 def __repr__(self):
89 self.raise_exc("__repr__")
90
91 class BrokenObj:
92 def __init__(self, exc):

Callers 1

test_baseexceptionFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_baseexceptionFunction · 0.68