§
    ÷yIfe  ã                  ó¶   — d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZ ddlmZ ddlmZ e
Zeeef         Zd d„ZdZdZd!d„Zd"d„Zd#d„Zefd$d„ZdS )%z,Utility functions for configuration testing.é    )ÚannotationsN)ÚPath)ÚAnyÚDict)ÚMock)ÚRunÚtested_configuration_fileú
str | PathÚsuffixÚstrÚdefaultÚreturnc                óJ  — |}t          | ¦  «        }|j        |j        › d|› �z  }|                     ¦   «         rSt	          |d¬¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   t          j        d|¦  «         nt          j        d||¦  «         |S )zKReturn the expected value from the file if it exists, or the given default.ú.Úutf8)ÚencodingNz
%s exists.z%s not found, using '%s'.)r   ÚparentÚstemÚexistsÚopenÚreadÚloggingÚinfo)r	   r   r   ÚexpectedÚpathÚexpected_result_pathÚfs          úW/var/www/piapp/venv/lib/python3.11/site-packages/pylint/testutils/configuration_test.pyÚget_expected_or_defaultr      sï   € ð €HÝÐ)Ñ*Ô*€DØœ;¨D¬IÐ)@Ð)@¸Ð)@Ð)@Ñ@ÐØ×"Ò"Ñ$Ô$ð QÝÐ&°Ð8Ñ8Ô8ð 	 ¸AØ—v’v‘x”xˆHð	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 õ
 	Œ�\Ð#7Ñ8Ô8Ð8Ð8åŒÐ0Ð2FÈÑPÔPÐPØ€Os   ÁA,Á,A0Á3A0Úfunctional_appendÚfunctional_removeÚconfiguration_pathÚdefault_configurationÚPylintConfigurationc                óÆ  — t          j        |¦  «        }t          | dd¬¦  «        }t          j        |¦  «        }|                     ¦   «         D ]‘\  }}|t          k    r+|                     ¦   «         D ]\  }}||xx         |z  cc<   ŒŒ;|t          k    rF|                     ¦   «         D ]0\  }}g }	||         D ]}
|
|vr|	                     |
¦  «         Œ|	||<   Œ1ŒŒ|||<   Œ’|S )zIGet the expected parsed configuration of a configuration functional test.zresult.jsonz{}©r   r   )	ÚcopyÚdeepcopyr   ÚjsonÚloadsÚitemsÚEXPECTED_CONF_APPEND_KEYÚEXPECTED_CONF_REMOVE_KEYÚappend)r"   r#   ÚresultÚconfig_as_jsonÚto_overrideÚkeyÚvalueÚfkeyÚfvalueÚ	new_valueÚ	old_values              r   Úget_expected_configurationr8   2   s$  € õ Œ]Ð0Ñ1Ô1€FÝ,Ø =¸$ðñ ô €Nõ ”*˜^Ñ,Ô,€KØ!×'Ò'Ñ)Ô)ð  ð  ‰
ˆˆUØÕ*Ò*Ð*Ø %§¢¡¤ð 'ð '‘��fØ�t��” Ñ&��‘�ð'àÕ,Ò,Ð,Ø %§¢¡¤ð )ð )‘��fØ�	Ø!'¨¤ð 4ð 4�IØ ¨Ð.Ð.Ø!×(Ò(¨Ñ3Ô3Ð3øØ(��t‘�ð)ð  ˆF�3‰KˆKØ€Mó    Úsuffix_filterú
list[Path]c                óp   ‡‡— t          | ¦  «        Šˆˆfd„‰j                             ¦   «         D ¦   «         S )zEReturn all the file related to a test conf file ending with a suffix.c                ó°   •— g | ]R}t          |j        ¦  «                             ‰j        ¦  «        ¯.t          |¦  «                             ‰¦  «        ¯P|‘ŒSS © )r   r   Ú
startswithÚendswith)Ú.0ÚpÚ	conf_pathr:   s     €€r   ú
<listcomp>z%get_related_files.<locals>.<listcomp>P   sc   ø€ ð ð ð àÝˆqŒv‰;Œ;×!Ò! )¤.Ñ1Ô1ðõ 7:¸!±f´f·o²oÀmÑ6TÔ6TðØ	ðð ð r9   )r   r   Úiterdir)r	   r:   rC   s    `@r   Úget_related_filesrF   K   sS   øø€ õ Ð.Ñ/Ô/€Iðð ð ð ð àÔ!×)Ò)Ñ+Ô+ðñ ô ð r9   Úuser_specific_pathr   útuple[int, str]c                ód  — d}d}t          | d¬¦  «        }t          |¦  «        dk    rt          j        d| |¦  «         dS |st          j        d¦  «         d	S |d         }	 t          t          |j        ¦  «                             d
d¬¦  «        d         ¦  «        }n/# t          $ r"}t          j        d| ||¦  «         Y d}~dS d}~ww xY wt          | |› d�d¬¦  «        }t          j        d| |¦  «         ||                     | t          | ¦  «                             |¦  «        ¬¦  «        fS )z-Get the expected output of a functional test.r   z—we expect a single file of the form 'filename.32.out' where 'filename' represents the name of the configuration file, and '32' the expected error code.Úout)r:   é   zToo much .out files for %s %s.)éÿÿÿÿzout file is brokenz9.out file does not exists, so the expected exit code is 0)r   Ú r   )ÚmaxsplitrL   z-Wrong format for .out file name for %s %s: %sNz.outrM   r&   z4Output exists for %s so the expected exit code is %s)ÚabspathÚrelpath)rF   Úlenr   Úerrorr   Úintr   r   ÚrsplitÚ	Exceptionr   Úformatr   Úrelative_to)r"   rG   Ú	exit_codeÚmsgÚpossible_out_filesr   ÚeÚoutputs           r   Úget_expected_outputr]   W   s›  € ð €Ið	Pð õ +Ð+=ÈUÐSÑSÔSÐÝ
ÐÑÔ Ò"Ð"ÝŒØ,ØØñ	
ô 	
ð 	
ð
 (Ð'Øð õ 	ŒÐPÑQÔQÐQØˆuØ˜aÔ €Dð	(Ý�˜DœI™œ×-Ò-¨c¸AÐ-Ñ>Ô>¸rÔBÑCÔCˆ	ˆ	øÝð (ð (ð (ÝŒØ;ØØØñ		
ô 	
ð 	
ð (Ð'Ð'Ð'Ð'Ð'øøøøð(øøøõ %Ø iÐ#5Ð#5Ð#5¸rðñ ô €Fõ „LØ>ØØñô ð ð
 �f—m’mØ"ÝÐ'Ñ(Ô(×4Ò4Ð5GÑHÔHð $ñ ô ð ð s   Á"<B Â
CÂ)CÃCú
Path | strÚfile_to_lintútuple[Mock, Mock, Run]c                ó2  — t          | ¦  «        } d| |g}t          j                             d¦  «        5 }d}t          j                             |¦  «        5 }t	          |¦  «        }ddd¦  «         n# 1 swxY w Y   ddd¦  «         n# 1 swxY w Y   |||fS )zHSimulate a run with a configuration without really launching the checks.z--rcfilezsys.exitz#pylint.lint.pylinter.check_parallelN)r   ÚunittestÚmockÚpatchr   )r"   r_   ÚargsÚmocked_exitÚcheckÚmocked_check_parallelÚrunners          r   Úrun_using_a_configuration_filerj   ˆ   s  € õ Ð/Ñ0Ô0ÐØÐ*¨LÐ9€Dõ 
Œ×	Ò	˜ZÑ	(Ô	(ð ¨Kð
 6ˆÝŒ]× Ò  Ñ'Ô'ð 	Ð+@Ý˜‘Y”YˆFð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð Ð-¨vÐ5Ð5s5   ´"B	ÁA2Á&B	Á2A6	Á6B	Á9A6	Á:B	Â	BÂB)r	   r
   r   r   r   r   r   r   )r"   r   r#   r$   r   r$   )r	   r
   r:   r   r   r;   )r"   r
   rG   r   r   rH   )r"   r^   r_   r   r   r`   )Ú__doc__Ú
__future__r   r'   r)   r   rb   Úpathlibr   Útypingr   r   Úunittest.mockr   Úpylint.lintr   ÚConfigurationValuer   r$   r   r,   r-   r8   rF   r]   Ú__file__rj   r>   r9   r   ú<module>rs      s2  ðð
 3Ð 2à "Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ð Ð Ø˜3Ð 2Ð2Ô3Ð ðð ð ð ð* /Ð Ø.Ð ðð ð ð ð2	ð 	ð 	ð 	ð.ð .ð .ð .ðd 9Að6ð 6ð 6ð 6ð 6ð 6ð 6r9   