~m ^ d dl Z d dlmZ d dlmZ G d de Z G d de ZdS ) N)checker)TestCasec @ e Zd ZdZed Zd Zd Zd Zd Z dS )TypeableVisitorTestsz&
Tests of L{_TypeableVisitor}
c ~ t j | }t j }| | |S )zV
Run L{_TypeableVisitor} on the parsed source and return the visitor.
)astparser _TypeableVisitorvisit)streevisitors l/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pyflakes/test/test_checker.py_run_visitorz!TypeableVisitorTests._run_visitor s6
y||*,,
d c | d }| |j g d | |j d t
j | |j d t
j | |j d t
j | |j d t
j dS )zA
Test that the typeable node types are collected
zx = 1 # assignment
for x in range(1): pass # for loop
def f(): pass # function definition
with a as b: pass # with statement
) r r r r N)
r assertEqualtypeable_linesassertIsInstancetypeable_nodesr AssignForFunctionDefWithselfr s r test_node_typesz$TypeableVisitorTests.test_node_types s ##
/>>>g4Q7DDDg4Q7AAAg4Q7IIIg4Q7BBBBBr c | d }| |j ddg | |j d t
j | |j d t
j dS )z
Test the common pitfall of missing `generic_visit` in visitors by
ensuring that nested nodes are reported
zdef f():
x = 1
r r N)r r r r r r r r r s r test_visitor_recursesz*TypeableVisitorTests.test_visitor_recurses( s
##
/!Q888g4Q7IIIg4Q7DDDDDr c l | d }| |j g d | |j d t
j | |j d t
j | |j d t
j dS )z@
Test that the PEP 492 node types are collected
zoasync def f(): # async def
async for x in y: pass # async for
async with a as b: pass # async with
)r r r r r r N) r r r r r r AsyncFunctionDefAsyncFor AsyncWithr s r test_py35_node_typesz)TypeableVisitorTests.test_py35_node_types7 s ##
/;;;g4Q79MNNNg4Q7FFFg4Q7GGGGGr c | d }| |j ddg | |j d j d j d dS )n
Test that when two typeable nodes are present on a line, the last
typeable one wins.
zx = 1; y = 1r r yN)r r r r targetsidr s r test_last_node_winsz(TypeableVisitorTests.test_last_node_winsG sc
##N33/!Q888/2:1=@#FFFFFr N)
__name__
__module____qualname____doc__staticmethodr r! r# r( r. r r r r s \C C C$
E
E
EH H H G G G G Gr r c j e Zd ZdZed Zd Zd Zd Zd Z d Z
d Zd Zd
Z
d Zd Zd
ZdS )CollectTypeCommentsTestsz,
Tests of L{_collect_type_comments}
c t j | }t j | }t j || }d | D S )z
Run L{_collect_type_comments} on the parsed source and return the
mapping from nodes to comments. The return value is converted to
a set: {(node_type, tuple of comments), ...}
c d h | ]-\ }}t | t d |D f.S )c 3 K | ] \ }}|V
d S )Nr4 ).0_r s r