From 6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Fri, 16 Jul 2021 21:58:21 +0100 Subject: bpo-44655: Don't include suggestions for attributes that are the same as the missing one (GH-27197) --- Lib/test/test_exceptions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_exceptions.py') diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 2b00147dc90..31051d4a8d0 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1916,6 +1916,18 @@ class AttributeErrorTests(unittest.TestCase): self.assertIn("blech", err.getvalue()) + def test_getattr_suggestions_for_same_name(self): + class A: + def __dir__(self): + return ['blech'] + try: + A().blech + except AttributeError as exc: + with support.captured_stderr() as err: + sys.__excepthook__(*sys.exc_info()) + + self.assertNotIn("Did you mean", err.getvalue()) + def test_attribute_error_with_failing_dict(self): class T: bluch = 1 -- cgit v1.2.3