o
    tBh)                     @  s   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 zddlZW n eyC   dZY nw ddlZejZg dZG dd	 d	eZdddZdddZd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                   @  s   e Zd ZeZdZd	ddZdS )
PythonCmdlineSuiteTtestcaser   returnNonec                 C  sH   t d u rtj|jdkrtd dgt|j D ]}t	|| qd S )Nr
   z$Cannot import lxml. Is it installed?   )
lxmlospathbasenamefilepytestskipsortedoutput2test_python_cmdline)selfr   step r   l/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/test/testcmdline.pyrun_case(   s
   
zPythonCmdlineSuite.run_caseN)r   r   r   r   )__name__
__module____qualname__cmdline_filesfiles
native_sepr   r   r   r   r   r   $   s    r   r   r   r   intr   r   c              	   C  s  | j d us	J dd}tjt|}t|ddd}| jD ]
}|| d qW d    n1 s2w   Y  t| jd }t	| jdkrLt
| jd nd }|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  tj|
 7  < tj|| tjtjtjt|pd|	d}| \}}|j}dd t|d D }dd t|d D }dtjv rt|D ]\}}|dr|||d =  nqt| | jr|s|rtd| j rd| nd|d|| f t!| | d S | j"rt#|| }|rdnd}||kr&|d|  |dkr.| j$n| j | }dd |D }t%||d&| j'| j(| j rKd| 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-mmypyCOLUMNSpypath
PYTHONPATH )stdoutstderrcwdenvc                 S     g | ]}| d qS z
rstrip.0sr   r   r   
<listcomp>N       z'test_python_cmdline.<locals>.<listcomp>c                 S  r3   r4   r5   r7   r   r   r   r:   O   r;   PYCHARM_HOSTEDzpydev debugger:    z6Expected zero status and empty stderr%s, got %d and
%sz on step %dz== Return code: c                 S  s   g | ]}| d tj dqS )tmpr.   )replacer   sepr7   r   r   r   r:   k   s    zInvalid output ({}, line {}){}))old_cwdr   r   joinr   openinputwrite
parse_argslen	parse_cwdappendpython3_pathenvironcopypopabspathr   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   r9   args
custom_cwdfixedr2   
extra_pathprocessoutberrbresultouterrposr`   obvious_resultexpected_outr   r   r   r   /   sx   
 







 
r   r`   rV   	list[str]c                 C  s"   t 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r`   mr   r   r   rF   u   s   rF   
str | Nonec                 C  s   t d| }|r|dS 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)rq   rr   rs   ru   r   r   r   rH      s   rH   )r   r   r   r%   r   r   )r`   rV   r   rp   )r`   rV   r   rw   )__doc__
__future__r   r   rq   rQ   sysmypy.test.configr   r   mypy.test.datar   r   mypy.test.helpersr   r   r	   r   ImportErrorr   
executablerJ   r"   r   r   rF   rH   r   r   r   r   <module>   s*    

F