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

Method test_unhashable

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

Source from the content-addressed store, hash-verified

3799 self.assertEqual(list(excs[0].format()), list(excs[1].format()))
3800
3801 def test_unhashable(self):
3802 class UnhashableException(Exception):
3803 def __eq__(self, other):
3804 return True
3805
3806 ex1 = UnhashableException('ex1')
3807 ex2 = UnhashableException('ex2')
3808 try:
3809 raise ex2 from ex1
3810 except UnhashableException:
3811 try:
3812 raise ex1
3813 except UnhashableException as e:
3814 exc_obj = e
3815 exc = traceback.TracebackException.from_exception(exc_obj)
3816 formatted = list(exc.format())
3817 self.assertIn('UnhashableException: ex2\n', formatted[2])
3818 self.assertIn('UnhashableException: ex1\n', formatted[6])
3819
3820 def test_limit(self):
3821 def recurse(n):

Callers

nothing calls this directly

Calls 5

listClass · 0.85
from_exceptionMethod · 0.80
assertInMethod · 0.80
UnhashableExceptionClass · 0.70
formatMethod · 0.45

Tested by

no test coverage detected