summaryrefslogtreecommitdiff
path: root/pyflakes/test/test_other.py
diff options
context:
space:
mode:
authorPhil Frost <indigo@bitglue.com>2015-08-14 12:00:37 -0400
committerPhil Frost <indigo@bitglue.com>2015-08-14 12:00:37 -0400
commit12653ca4dcf56f10ac041dae7a916e86343239ca (patch)
tree755eec69d175afa186c502361f59bd545d31363d /pyflakes/test/test_other.py
parent1c5bbdf79f4ef387cd6d96f565fd262678c4c552 (diff)
parentec8dbbb30a2a5ad8a1522d5b474b942e1eef98c5 (diff)
downloadpyflakes-12653ca4dcf56f10ac041dae7a916e86343239ca.tar.gz
Merge pull request #26 from ryneeverett/unused-reassigned-variable
Add tests to document hard to test cases It would be nice if shadowing an unused variable was an error, but this is quite difficult to implement in a way which does not also raise false positives in the context of loops.
Diffstat (limited to 'pyflakes/test/test_other.py')
-rw-r--r--pyflakes/test/test_other.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py
index ac116c8..718d16f 100644
--- a/pyflakes/test/test_other.py
+++ b/pyflakes/test/test_other.py
@@ -523,6 +523,30 @@ class TestUnusedAssignment(TestCase):
return
''', m.UnusedVariable)
+ @skip("todo: Difficult because it does't apply in the context of a loop")
+ def test_unusedReassignedVariable(self):
+ """
+ Shadowing a used variable can still raise an UnusedVariable warning.
+ """
+ self.flakes('''
+ def a():
+ b = 1
+ b.foo()
+ b = 2
+ ''', m.UnusedVariable)
+
+ def test_variableUsedInLoop(self):
+ """
+ Shadowing a used variable cannot raise an UnusedVariable warning in the
+ context of a loop.
+ """
+ self.flakes('''
+ def a():
+ b = True
+ while b:
+ b = False
+ ''')
+
def test_assignToGlobal(self):
"""
Assigning to a global and then not using that global is perfectly