MCPcopy Index your code
hub / github.com/python/cpython / test_unhashable

Method test_unhashable

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

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected