(self)
| 2208 | |
| 2209 | @cpython_only |
| 2210 | def test_unhashable(self): |
| 2211 | from _testcapi import exception_print |
| 2212 | |
| 2213 | class UnhashableException(Exception): |
| 2214 | def __eq__(self, other): |
| 2215 | return True |
| 2216 | |
| 2217 | ex1 = UnhashableException('ex1') |
| 2218 | ex2 = UnhashableException('ex2') |
| 2219 | try: |
| 2220 | raise ex2 from ex1 |
| 2221 | except UnhashableException: |
| 2222 | try: |
| 2223 | raise ex1 |
| 2224 | except UnhashableException as e: |
| 2225 | exc_val = e |
| 2226 | |
| 2227 | with captured_output("stderr") as stderr_f: |
| 2228 | exception_print(exc_val) |
| 2229 | |
| 2230 | tb = stderr_f.getvalue().strip().splitlines() |
| 2231 | self.assertEqual(11, len(tb)) |
| 2232 | self.assertEqual(context_message.strip(), tb[5]) |
| 2233 | self.assertIn('UnhashableException: ex2', tb[3]) |
| 2234 | self.assertIn('UnhashableException: ex1', tb[10]) |
| 2235 | |
| 2236 | def deep_eg(self): |
| 2237 | e = TypeError(1) |
nothing calls this directly
no test coverage detected