aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-04-16 17:12:03 +0100
committerGitHub <noreply@github.com>2021-04-16 17:12:03 +0100
commit0ad81d4db2f409d72f469d0b74ab597be772a68e (patch)
tree3b8c64cda42f229d3cc3522b380840d6bdd10638 /Lib/test/test_exceptions.py
parent3b82cae774638ecf2baaee8fe2cac8fedafb2ca7 (diff)
downloadcpython-0ad81d4db2f409d72f469d0b74ab597be772a68e.tar.gz
cpython-0ad81d4db2f409d72f469d0b74ab597be772a68e.zip
bpo-38530: Match exactly AttributeError and NameError when offering suggestions (GH-25443)
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index ebeb67b4512..bd20b232e54 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1537,6 +1537,21 @@ class NameErrorTests(unittest.TestCase):
self.assertNotIn("blech", err.getvalue())
+ def test_unbound_local_error_doesn_not_match(self):
+ def foo():
+ something = 3
+ print(somethong)
+ somethong = 3
+
+ try:
+ foo()
+ except UnboundLocalError as exc:
+ with support.captured_stderr() as err:
+ sys.__excepthook__(*sys.exc_info())
+
+ self.assertNotIn("something", err.getvalue())
+
+
class AttributeErrorTests(unittest.TestCase):
def test_attributes(self):
# Setting 'attr' should not be a problem.