mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Fix reporting of UndefinedLocal pyflakes error
This commit is contained in:
parent
79148a02ee
commit
8df38c92b9
2 changed files with 23 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
"""Tests of pyflakes monkey patches."""
|
||||
import ast
|
||||
|
||||
import pyflakes
|
||||
|
||||
|
|
@ -13,3 +14,20 @@ def test_all_pyflakes_messages_have_flake8_codes_assigned():
|
|||
if name[0].isupper() and obj.message
|
||||
}
|
||||
assert messages == set(pyflakes_shim.FLAKE8_PYFLAKES_CODES)
|
||||
|
||||
|
||||
def test_undefined_local_code():
|
||||
"""In pyflakes 2.1.0 this code's string formatting was changed."""
|
||||
src = '''\
|
||||
import sys
|
||||
|
||||
def f():
|
||||
sys = sys
|
||||
'''
|
||||
tree = ast.parse(src)
|
||||
checker = pyflakes_shim.FlakesChecker(tree, (), 't.py')
|
||||
message_texts = [s for _, _, s, _ in checker.run()]
|
||||
assert message_texts == [
|
||||
"F823 local variable 'sys' defined in enclosing scope on line 1 referenced before assignment", # noqa: E501
|
||||
"F841 local variable 'sys' is assigned to but never used",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue