MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_unhashable

Method test_unhashable

Lib/test/test_traceback.py:2283–2307  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 8

captured_outputFunction · 0.90
lenFunction · 0.85
assertInMethod · 0.80
UnhashableExceptionClass · 0.70
splitlinesMethod · 0.45
stripMethod · 0.45
getvalueMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected