
    c                        d dl mZ d dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZ d dlmZ d dlmZ d d	lmZ d d
lmZ  G d d          ZdS )    )annotationsN)	GeneratorIterator)Any)nodes)IS_PYPY	PY38_PLUS	PY39_PLUS)linter)MessageTest)UnittestLinter)	ASTWalkerc                      e Zd ZU dZded<   i Zded<   ddZej        dd
            Z	ej        dddd            Z
ddZdS )CheckerTestCasezBA base testcase class for unit testing individual checker classes.r   CHECKER_CLASSzdict[str, Any]CONFIGreturnNonec                   t                      | _        |                     | j                  | _        | j                                        D ]%\  }}t          | j        j        j        ||           &| j                                         d S N)	r   r   r   checkerr   itemssetattrconfigopen)selfkeyvalues      Blib/python3.11/site-packages/pylint/testutils/checker_test_case.pysetup_methodzCheckerTestCase.setup_method   s~    $&&))$+66+++-- 	< 	<JCDL'.U;;;;    Iterator[None]c              #  l   K   |                                  5  dV  ddd           dS # 1 swxY w Y   dS )z6Assert that no messages are added by the given method.N)assertAddsMessages)r   s    r   assertNoMessagesz CheckerTestCase.assertNoMessages$   s       $$&& 	 	EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   )--F)ignore_positionmessagesr   r&   boolGenerator[None, None, None]c             '    K   dV  | j                                         }d}d                    d |D                       p|}d                    d |D                       p|}d| d| d}t          |          t          |          k    s
J |            t	          ||          D ] \  }}	|j        |	j        k    s
J |            |j        |	j        k    s
J |            |j        |	j        k    s
J |            |j        |	j        k    s
J |            |rq|j	        |	j	        k    s
J |            |j
        |	j
        k    s
J |            t          rt          rt          rf|j        |	j        k    s#t          j        d|	 d	| d
t"          d           |j        |	j        k    s#t          j        d|	 d	| dt"          d           "dS )a  Assert that exactly the given method adds the given messages.

        The list of messages must exactly match *all* the messages added by the
        method. Additionally, we check to see whether the args in each message can
        actually be substituted into the message string.

        Using the keyword argument `ignore_position`, all checks for position
        arguments (line, col_offset, ...) will be skipped. This can be used to
        just test messages for the correct node.
        NzNo message.
c              3  4   K   | ]}t          |          V  d S r   repr.0ms     r   	<genexpr>z5CheckerTestCase.assertAddsMessages.<locals>.<genexpr>;   s(      77T!WW777777r!   c              3  4   K   | ]}t          |          V  d S r   r-   r/   s     r   r2   z5CheckerTestCase.assertAddsMessages.<locals>.<genexpr><   s(      11DGG111111r!   z3Expected messages did not match actual.

Expected:
z

Got:
zThe end_line attribute of z& does not match the expected value in zM. In pylint 3.0 correct end_line attributes will be required for MessageTest.   )
stacklevelz The end_col_offset attribute of zS. In pylint 3.0 correct end_col_offset attributes will be required for MessageTest.)r   release_messagesjoinlenzipmsg_idnodeargs
confidenceline
col_offsetr	   r   r
   end_linewarningswarnDeprecationWarningend_col_offset)
r   r&   r'   gotno_msgexpectedgot_strmsgexpected_msg
gotten_msgs
             r   r$   z"CheckerTestCase.assertAddsMessages*   s      	k**,,9977h77777A6))11S11111;V<$< <07< < < 	
 8}}C(--#---(+Hc(:(: 	 	$L*&**;;@@S@@@$
7<<<<<$
7<<<<<*j.CCHHSHHH $
7<<<<<*j.CCHHSHHH  I #,
0CC MGZ G G1=G G G +#$    $2j6OO MG: G G1=G G G +#$   /	 	r!   r;   nodes.NodeNGc                    t          t                    }|                    | j                   |                    |           dS )z!Recursive walk on the given node.N)r   r   add_checkerr   walk)r   r;   walkers      r   rO   zCheckerTestCase.walkc   s=    6""4<(((Dr!   N)r   r   )r   r"   )r'   r   r&   r(   r   r)   )r;   rL   r   r   )__name__
__module____qualname____doc____annotations__r   r    
contextlibcontextmanagerr%   r$   rO    r!   r   r   r      s         LL F       
 >C6 6 6 6 6 6p     r!   r   )
__future__r   rV   rA   collections.abcr   r   typingr   astroidr   pylint.constantsr   r	   r
   #pylint.testutils.global_test_linterr   pylint.testutils.output_liner    pylint.testutils.unittest_linterr   pylint.utilsr   r   rX   r!   r   <module>rb      s  
 # " " " " "      / / / / / / / /             : : : : : : : : : : 6 6 6 6 6 6 4 4 4 4 4 4 ; ; ; ; ; ; " " " " " "R R R R R R R R R Rr!   