
    X-Ph                        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m	Z	 ddl
mZmZ ddlmZmZmZ 	 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)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      U/var/www/html/test/jupyter/venv/lib/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           
        | 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           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--no-force-uppercase-builtinsz--force-uppercase-builtinsz--no-force-union-syntaxz--force-union-syntaxz-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>M   s5    FFF#CKK 4 455FFFr!   )stdoutstderrr9   envc                8    g | ]}|                     d           S z
rstripr7   ss     r   r:   z'test_python_cmdline.<locals>.<listcomp>T   $    
D
D
D188F
D
D
Dr!   c                8    g | ]}|                     d           S r?   r@   rB   s     r   r:   z'test_python_cmdline.<locals>.<listcomp>U   rD   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 )tmpr3   )r5   r   seprB   s     r   r:   z'test_python_cmdline.<locals>.<listcomp>q   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popr6   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   rC   args
custom_cwdfixedr=   
extra_pathprocessoutberrbresultouterrposri   obvious_resultexpected_outr9   s                        @r   r   r   /   s   '')G'''G7<<w77L	lC&	1	1	1 !T 	! 	!AJJ!xxx    	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! hnQ'((D14X^1D1Dq1H1H8>!,---dJKK"###$$()))4''())) ,,*+++&d220111 ,,*+++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 ri   r_   	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ri   ms     r   rP   rP   {   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   rR   rR      s.     	&&A$1771:::$r!   )r   r   r   r)   r   r   )ri   r_   r   ry   )ri   r_   r   r   )__doc__
__future__r   r   r{   rZ   sysmypy.test.configr   r   mypy.test.datar   r   mypy.test.helpersr   r	   r
   r   ImportErrorr   
executablerT   r%   r   r   rP   rR   r(   r!   r   <module>r      sw    # " " " " " 				 				     



 2 2 2 2 2 2 2 2 8 8 8 8 8 8 8 8         KKKK   DDD  ~ [ZZ0 0 0 0 0 0 0 0I
 I
 I
 I
X   "% % % % % %s   9 AA