summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFantix King <fantix@uchicago.edu>2019-02-22 10:47:38 -0600
committerClaudiu Popa <pcmanticore@gmail.com>2019-02-22 18:09:53 +0100
commitb18acace2194aab6db409e002a50ecf65cfe0aa9 (patch)
tree9f670d03ceaa44eadacbaf54b11733d2b93153ac
parent15e405f20c9432f50c677a4026adc76124716861 (diff)
downloadpylint-git-b18acace2194aab6db409e002a50ecf65cfe0aa9.tar.gz
CRF: added a separate test for the bugfix
-rw-r--r--pylint/test/functional/useless_else_on_loop.py17
-rw-r--r--pylint/test/functional/useless_else_on_loop.txt2
2 files changed, 16 insertions, 3 deletions
diff --git a/pylint/test/functional/useless_else_on_loop.py b/pylint/test/functional/useless_else_on_loop.py
index 8fd178798..d686f4658 100644
--- a/pylint/test/functional/useless_else_on_loop.py
+++ b/pylint/test/functional/useless_else_on_loop.py
@@ -67,8 +67,7 @@ def test_break_in_orelse_deep():
if 3 < 2:
break
else:
- if 1 < 2:
- break
+ break
else:
return True
return False
@@ -88,3 +87,17 @@ def test_break_in_orelse_deep2():
else: # [useless-else-on-loop]
return True
return False
+
+
+def test_break_in_orelse_deep3():
+ """no false positive for break deeply nested in else
+ """
+ for _ in range(10):
+ for _ in range(3):
+ pass
+ else:
+ if 1 < 2:
+ break
+ else:
+ return True
+ return False
diff --git a/pylint/test/functional/useless_else_on_loop.txt b/pylint/test/functional/useless_else_on_loop.txt
index 0d561011f..efa1161ab 100644
--- a/pylint/test/functional/useless_else_on_loop.txt
+++ b/pylint/test/functional/useless_else_on_loop.txt
@@ -3,4 +3,4 @@ useless-else-on-loop:18:test_return_while:Else clause on loop without a break st
useless-else-on-loop:28::Else clause on loop without a break statement
useless-else-on-loop:35::Else clause on loop without a break statement
useless-else-on-loop:40::Else clause on loop without a break statement
-useless-else-on-loop:88:test_break_in_orelse_deep2:Else clause on loop without a break statement
+useless-else-on-loop:87:test_break_in_orelse_deep2:Else clause on loop without a break statement