(self)
| 2281 | |
| 2282 | @cpython_only |
| 2283 | def test_unhashable(self): |
| 2284 | from _testcapi import exception_print |
| 2285 | |
| 2286 | class UnhashableException(Exception): |
| 2287 | def __eq__(self, other): |
| 2288 | return True |
| 2289 | |
| 2290 | ex1 = UnhashableException('ex1') |
| 2291 | ex2 = UnhashableException('ex2') |
| 2292 | try: |
| 2293 | raise ex2 from ex1 |
| 2294 | except UnhashableException: |
| 2295 | try: |
| 2296 | raise ex1 |
| 2297 | except UnhashableException as e: |
| 2298 | exc_val = e |
| 2299 | |
| 2300 | with captured_output("stderr") as stderr_f: |
| 2301 | exception_print(exc_val) |
| 2302 | |
| 2303 | tb = stderr_f.getvalue().strip().splitlines() |
| 2304 | self.assertEqual(11, len(tb)) |
| 2305 | self.assertEqual(context_message.strip(), tb[5]) |
| 2306 | self.assertIn('UnhashableException: ex2', tb[3]) |
| 2307 | self.assertIn('UnhashableException: ex1', tb[10]) |
| 2308 | |
| 2309 | def deep_eg(self): |
| 2310 | e = TypeError(1) |
nothing calls this directly
no test coverage detected