
    i                    8   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Zddlm	Z	m
Z
 ddlmZmZ ddlmZmZmZ 	 ej        dk    r e ej        d                    rdZnddlZn# e$ r dZY nw xY wddlZej        Zg d	Z G d
 de          ZddZddZddZdS )zsTest cases for the command line.

To begin we test that "mypy <directory>[/]" always recurses down the
whole tree.
    )annotationsN)PREFIXtest_temp_dir)DataDrivenTestCase	DataSuite)assert_string_arrays_equalcheck_test_output_filesnormalize_error_messages)      Py_GIL_DISABLED)zcmdline.testzcmdline.pyproject.testreports.testzenvvars.testc                      e Zd ZeZdZddZdS )	PythonCmdlineSuiteTtestcaser   returnNonec                    t           <t          j                            |j                  dk    rt          j        d           dgt          |j                  z   D ]}t          ||           d S )Nr   z$Cannot import lxml. Is it installed?   )
lxmlospathbasenamefilepytestskipsortedoutput2test_python_cmdline)selfr   steps      T/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypy/test/testcmdline.pyrun_casezPythonCmdlineSuite.run_case-   sr    <BG,,X];;~MMK>???C&!1222 	0 	0D$////	0 	0    N)r   r   r   r   )__name__
__module____qualname__cmdline_filesfiles
native_sepr#    r$   r"   r   r   )   s2        EJ0 0 0 0 0 0r$   r   r   r   r!   intr   r   c           
     B   | j         
J d            d}t          j                            t          |          }t          |dd          5 }| j        D ]}|                    | d           	 d d d            n# 1 swxY w Y   t          | j        d                   }t          | j                  dk    rt          | j        d                   nd }|                    d	           d
|vr|                    d           d|vr|                    d           d|vr|                    d           t          ddg}t          j                                        }	|	                    dd            t          j                            t          j                            t                    d          }
t"          |	d<   t          j                            |
          r|	dxx         t          j        |
z   z  cc<   t          j                            t          |pd          fd|D             }t)          j        ||z   t(          j        t(          j        |	          }|                                \  }}|j        }d t3          |d                                          D             }d t3          |d                                          D             }dt          j        v r4t7          |          D ]$\  }}|                    d          r
|||dz   =  n%t          j        |           | j        rM|s|r7t?          d| j         rd|z  nd|d                    ||z             fz            tC          | |           d S | j"        rtG          ||z             }|rdnd}||k    r|                    d|            |dk    r| j$        n| j         |         }d  |D             }tK          ||d!&                    | j'        | j(        | j         rd|z  nd                     d S )"Nztest was not properly set upz_program.pywutf8)encoding
r   r   z--show-tracebackz--error-summaryz--no-error-summaryz--show-error-codesz--hide-error-codesz--disallow-empty-bodiesz--allow-empty-bodiesz-mmypyCOLUMNSpypath
PYTHONPATH c                v    g | ]5}|                     d t          j                                                6S )z$CWD)replacer   r   abspath).0argcwds     r"   
<listcomp>z'test_python_cmdline.<locals>.<listcomp>N   s5    FFF#CKK 4 455FFFr$   )stdoutstderrr<   envc                8    g | ]}|                     d           S z
rstripr:   ss     r"   r=   z'test_python_cmdline.<locals>.<listcomp>U   $    
D
D
D188F
D
D
Dr$   c                8    g | ]}|                     d           S rB   rC   rE   s     r"   r=   z'test_python_cmdline.<locals>.<listcomp>V   rG   r$   PYCHARM_HOSTEDzpydev debugger:    z6Expected zero status and empty stderr%s, got %d and
%sz on step %dz== Return code: c                T    g | ]%}|                     d t          j        z   d          &S )tmpr6   )r8   r   seprE   s     r"   r=   z'test_python_cmdline.<locals>.<listcomp>r   s,    LLL!		%"&."55LLLr$   zInvalid output ({}, line {}){}))old_cwdr   r   joinr   openinputwrite
parse_argslen	parse_cwdappendpython3_pathenvironcopypopr9   r   isdirpathsep
subprocessPopenPIPEcommunicate
returncodestr
splitlines	enumerate
startswithremoveoutput_filesAssertionErrorr   r	   normalize_outputr
   outputr   formatr   line)r   r!   programprogram_pathr   rF   args
custom_cwdfixedr@   
extra_pathprocessoutberrbresultouterrposrl   obvious_resultexpected_outr<   s                        @r"   r   r   4   s   '')G'''G7<<w77L	lC&	1	1	1 !T 	! 	!AJJ!xxx    	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! hnQ'((D14X^1D1Dq1H1H8>!,---dJKK"###$$()))4''())) ,,*+++4(E
*//

CGGItbgoom<<hGGJC	w}}Z   5LRZ*44
',,}j&6B
7
7CFFFFFFFDZ_Z_#SV  G $$&&JD$F
D
DSv%6%6%A%A%C%C
D
D
DC
D
DSv%6%6%A%A%C%C
D
D
DC2:%%"3 	 	IC122 cAg& Il 
 	& 	 I+3+;C=4''VTYYWZ]`W`MaMabc   	 $/////$ 	6*3955C!qV##JJ2&22333*.!))x9I$9OLL|LLL",33x}hFV.^md.B.B\^ 	
 	
 	
 	
 	
s   #A<<B B rl   rb   	list[str]c                    t          j        d|           }|sg S |                    d                                          S )zParse the first line of the program for the command line.

    This should have the form

      # cmd: mypy <options>

    For example:

      # cmd: mypy pkg/
    z# cmd: mypy (.*)$r   )rematchgroupsplitrl   ms     r"   rS   rS   |   s?     	$d++A 	771::r$   
str | Nonec                ^    t          j        d|           }|r|                    d          ndS )zParse the second line of the program for the command line.

    This should have the form

      # cwd: <directory>

    For example:

      # cwd: main/subdir
    z# cwd: (.*)$r   N)r~   r   r   r   s     r"   rU   rU      s.     	&&A$1771:::$r$   )r   r   r!   r,   r   r   )rl   rb   r   r|   )rl   rb   r   r   )__doc__
__future__r   r   r~   r]   sys	sysconfigmypy.test.configr   r   mypy.test.datar   r   mypy.test.helpersr   r	   r
   version_infoboolget_config_varr   ImportErrorr   
executablerW   r(   r   r   rS   rU   r+   r$   r"   <module>r      s    # " " " " " 				 				     



     2 2 2 2 2 2 2 2 8 8 8 8 8 8 8 8         
7""tt,DI,DEV,W,W'X'X"   DDD  ~ [ZZ0 0 0 0 0 0 0 0E
 E
 E
 E
P   "% % % % % %s   +A$ $A.-A.