diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-08-08 08:42:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-08 08:42:54 +0300 |
commit | 662db125cddbca1db68116c547c290eb3943d98e (patch) | |
tree | 06151487dbe4493ef173dd8cc378f4b6cf5c0e4a /Lib/test/test_traceback.py | |
parent | 4c69be22df3852f17873a74d015528d9a8ae92d6 (diff) | |
download | cpython-git-662db125cddbca1db68116c547c290eb3943d98e.tar.gz |
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r-- | Lib/test/test_traceback.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 96d85e2cb8..72dc7afb8c 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -7,7 +7,7 @@ import sys import unittest import re from test import support -from test.support import TESTFN, Error, captured_output, unlink, cpython_only +from test.support import TESTFN, Error, captured_output, unlink, cpython_only, ALWAYS_EQ from test.support.script_helper import assert_python_ok import textwrap @@ -887,6 +887,8 @@ class TestFrame(unittest.TestCase): # operator fallbacks to FrameSummary.__eq__. self.assertEqual(tuple(f), f) self.assertIsNone(f.locals) + self.assertNotEqual(f, object()) + self.assertEqual(f, ALWAYS_EQ) def test_lazy_lines(self): linecache.clearcache() @@ -1083,6 +1085,18 @@ class TestTracebackException(unittest.TestCase): self.assertEqual(exc_info[0], exc.exc_type) self.assertEqual(str(exc_info[1]), str(exc)) + def test_comparison(self): + try: + 1/0 + except Exception: + exc_info = sys.exc_info() + exc = traceback.TracebackException(*exc_info) + exc2 = traceback.TracebackException(*exc_info) + self.assertIsNot(exc, exc2) + self.assertEqual(exc, exc2) + self.assertNotEqual(exc, object()) + self.assertEqual(exc, ALWAYS_EQ) + def test_unhashable(self): class UnhashableException(Exception): def __eq__(self, other): |