관리-도구
편집 파일: test_checker.cpython-311.pyc
� �܋f � �^ � 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. )�ast�parser �_TypeableVisitor�visit)�s�tree�visitors �k/builddir/build/BUILD/cloudlinux-venv-1.0.6/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 z�x = 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 �assertEqual�typeable_lines�assertIsInstance�typeable_nodesr �Assign�For�FunctionDef�With��selfr s r �test_node_typesz$TypeableVisitorTests.test_node_types s� � � �#�#� � � �� ����/����>�>�>����g�4�Q�7���D�D�D����g�4�Q�7���A�A�A����g�4�Q�7���I�I�I����g�4�Q�7���B�B�B�B�Br 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� � � �#�#� � � �� ����/�!�Q��8�8�8����g�4�Q�7���I�I�I����g�4�Q�7���D�D�D�D�Dr 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 �AsyncFunctionDef�AsyncFor� AsyncWithr s r �test_py35_node_typesz)TypeableVisitorTests.test_py35_node_types7 s� � � �#�#� � � �� ����/����;�;�;����g�4�Q�7��9M�N�N�N����g�4�Q�7���F�F�F����g�4�Q�7���G�G�G�G�Gr 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 �targets�idr s r �test_last_node_winsz(TypeableVisitorTests.test_last_node_winsG sc � � �#�#�N�3�3������/�!�Q��8�8�8�����/��2�:�1�=�@�#�F�F�F�F�Fr N) �__name__� __module__�__qualname__�__doc__�staticmethodr r! r# r( r. � r r r r s� � � � � � �� � �� � �\��C� C� C�$ E� E� E�H� 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 � <genexpr>z>CollectTypeCommentsTests._collect.<locals>.<setcomp>.<genexpr>b s&