summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorfly <fly@users.noreply.github.com>2023-01-12 20:49:18 +0100
committerGitHub <noreply@github.com>2023-01-12 20:49:18 +0100
commit0c5ab132e262280da98742e5cf73ecc1cbfa7377 (patch)
treea9e588c59d3e5f7f7b7d6fe957b07236ab4d5ba5 /tests
parente487a4659dcaeb7a48b084b2acbe5274583b1e3a (diff)
downloadpylint-git-0c5ab132e262280da98742e5cf73ecc1cbfa7377.tar.gz
Fixes false positive for `try-except-raise` with multiple exceptions in one except statement if exception are in different namespace (#8052)
Closes #8051
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/t/try_except_raise.py14
-rw-r--r--tests/functional/t/try_except_raise.txt2
2 files changed, 14 insertions, 2 deletions
diff --git a/tests/functional/t/try_except_raise.py b/tests/functional/t/try_except_raise.py
index 006a29bf9..b82a4bba1 100644
--- a/tests/functional/t/try_except_raise.py
+++ b/tests/functional/t/try_except_raise.py
@@ -1,5 +1,5 @@
# pylint:disable=missing-docstring, unreachable, bad-except-order, bare-except, unnecessary-pass
-# pylint: disable=undefined-variable, broad-except, raise-missing-from
+# pylint: disable=undefined-variable, broad-except, raise-missing-from, too-few-public-methods
try:
int("9a")
except: # [try-except-raise]
@@ -81,6 +81,18 @@ except (FileNotFoundError, PermissionError):
except OSError:
print("a failure")
+class NameSpace:
+ error1 = FileNotFoundError
+ error2 = PermissionError
+ parent_error=OSError
+
+try:
+ pass
+except (NameSpace.error1, NameSpace.error2):
+ raise
+except NameSpace.parent_error:
+ print("a failure")
+
# also consider tuples for subsequent exception handler instead of just bare except handler
try:
pass
diff --git a/tests/functional/t/try_except_raise.txt b/tests/functional/t/try_except_raise.txt
index 20181fa7f..7145e07b7 100644
--- a/tests/functional/t/try_except_raise.txt
+++ b/tests/functional/t/try_except_raise.txt
@@ -3,4 +3,4 @@ try-except-raise:16:0:18:29::The except handler raises immediately:UNDEFINED
try-except-raise:53:4:54:13:ddd:The except handler raises immediately:UNDEFINED
try-except-raise:67:0:68:9::The except handler raises immediately:UNDEFINED
try-except-raise:72:0:73:9::The except handler raises immediately:UNDEFINED
-try-except-raise:94:0:95:9::The except handler raises immediately:UNDEFINED
+try-except-raise:106:0:107:9::The except handler raises immediately:UNDEFINED