make sure the name of the exception is added in the scope of the exception - fixes #10

This commit is contained in:
Tarek Ziade 2012-02-21 10:43:16 +01:00
parent b1690f818d
commit 1003eeabe8
2 changed files with 22 additions and 2 deletions

View file

@ -329,7 +329,10 @@ class Checker(object):
EQ = NOTEQ = LT = LTE = GT = GTE = IS = ISNOT = IN = NOTIN = ignore
# additional node types
COMPREHENSION = EXCEPTHANDLER = KEYWORD = handleChildren
COMPREHENSION = KEYWORD = handleChildren
def EXCEPTHANDLER(self, node):
self.scope[node.name] = node
def addBinding(self, lineno, value, reportRedef=True):
'''Called when a binding is altered.
@ -645,7 +648,7 @@ def checkPath(filename):
return 1
def check(codeString, filename):
def check(codeString, filename='(code)'):
"""
Check the Python source given by C{codeString} for flakes.

View file

@ -0,0 +1,17 @@
from unittest import TestCase
from flake8.pyflakes import check
code = """
try:
pass
except ValueError as err:
print(err)
"""
class TestFlake(TestCase):
def test_exception(self):
warnings = check(code)
self.assertEqual(warnings, 0)