o
    g                     @   sR   d dl 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
 G dd dZdS )    N)DictOptionalType)linter)UnittestLinter)	ASTWalkerc                   @   sZ   e Zd ZU dZdZee ed< i Ze	ed< dd Z
ejdd Zejd	d
 Zdd ZdS )CheckerTestCasezBA base testcase class for unit testing individual checker classes.NCHECKER_CLASSCONFIGc                 C   sH   t  | _| | j| _| j D ]\}}t| jj|| q| j  d S N)	r   r   r	   checkerr
   itemssetattrconfigopen)selfkeyvalue r   `/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/testutils/checker_test_case.pysetup_method   s
   zCheckerTestCase.setup_methodc                 c   s6    |    dV  W d   dS 1 sw   Y  dS )z6Assert that no messages are added by the given method.N)assertAddsMessages)r   r   r   r   assertNoMessages   s   
"z CheckerTestCase.assertNoMessagesc                 g   sp    dV  | j  }d}ddd |D p|}ddd |D p"|}d| d| d}|t|ks6J |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.
        NzNo message.
c                 s       | ]}t |V  qd S r   repr.0mr   r   r   	<genexpr>*       z5CheckerTestCase.assertAddsMessages.<locals>.<genexpr>c                 s   r   r   r   r   r   r   r   r    +   r!   z3Expected messages did not match actual.

Expected:
z

Got:
)r   release_messagesjoinlist)r   messagesgotno_msgexpectedgot_strmsgr   r   r   r      s   
z"CheckerTestCase.assertAddsMessagesc                 C   s"   t t}|| j || dS )z recursive walk on the given nodeN)r   r   add_checkerr   walk)r   nodewalkerr   r   r   r,   2   s   zCheckerTestCase.walk)__name__
__module____qualname____doc__r	   r   r   __annotations__r
   r   r   
contextlibcontextmanagerr   r   r,   r   r   r   r   r      s   
 

r   )r4   typingr   r   r   #pylint.testutils.global_test_linterr    pylint.testutils.unittest_linterr   pylint.utilsr   r   r   r   r   r   <module>   s   