diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-10-17 15:14:19 -0700 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-10-18 01:14:19 +0300 |
commit | 2712247ec94dcc12cf9abeec78f18f54fcc3357a (patch) | |
tree | 75e8771fb391d7f199ed20cc464cb93724b72f39 /Lib/idlelib/idle_test/test_run.py | |
parent | 858ea4354fafa36e57859d2dfd70f8a057984075 (diff) | |
download | cpython-git-2712247ec94dcc12cf9abeec78f18f54fcc3357a.tar.gz |
[3.6] bpo-28603: Fix formatting tracebacks for unhashable exceptions (GH-4014) (#4024)
(cherry picked from commit de86073a761cd3539aaca6f886a1f55effc0d9da)
Diffstat (limited to 'Lib/idlelib/idle_test/test_run.py')
-rw-r--r-- | Lib/idlelib/idle_test/test_run.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/idlelib/idle_test/test_run.py b/Lib/idlelib/idle_test/test_run.py new file mode 100644 index 0000000000..d7e627d23d --- /dev/null +++ b/Lib/idlelib/idle_test/test_run.py @@ -0,0 +1,35 @@ +import unittest +from unittest import mock + +from test.support import captured_stderr +import idlelib.run as idlerun + + +class RunTest(unittest.TestCase): + def test_print_exception_unhashable(self): + class UnhashableException(Exception): + def __eq__(self, other): + return True + + ex1 = UnhashableException('ex1') + ex2 = UnhashableException('ex2') + try: + raise ex2 from ex1 + except UnhashableException: + try: + raise ex1 + except UnhashableException: + with captured_stderr() as output: + with mock.patch.object(idlerun, + 'cleanup_traceback') as ct: + ct.side_effect = lambda t, e: t + idlerun.print_exception() + + tb = output.getvalue().strip().splitlines() + self.assertEqual(11, len(tb)) + self.assertIn('UnhashableException: ex2', tb[3]) + self.assertIn('UnhashableException: ex1', tb[10]) + + +if __name__ == '__main__': + unittest.main(verbosity=2) |