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