diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-07-16 20:58:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-16 20:58:21 (GMT) |
commit | 6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d (patch) | |
tree | b243c5db97cf18198e8a080e400edd9b06c34f03 /Lib | |
parent | c90c591e5158ab7b531dcd6e2a5f00bc70ba7637 (diff) | |
download | cpython-6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d.zip cpython-6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d.tar.gz cpython-6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d.tar.bz2 |
bpo-44655: Don't include suggestions for attributes that are the same as the missing one (GH-27197)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_exceptions.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 2b00147..31051d4 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 |