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Zddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZmZ dd	lmZmZ ejZed
ZG dd deZdddZdddZdS )a  Test cases for running mypy programs using a Python interpreter.

Each test case type checks a program then runs it using Python. The
output (stdout) of the program is compared to expected output. Type checking
uses full builtins and other stubs.

Note: Currently Python interpreter paths are hard coded.

Note: These test cases are *not* included in the main test suite, as including
      this suite would slow down the main suite too much.
    )annotationsN)TemporaryDirectory)api)PYTHON3_VERSION)test_temp_dir)DataDrivenTestCase	DataSuite)assert_string_arrays_equalsplit_linesz\b_program.py\bc                   @  s$   e Zd ZddgZe Zd
ddZd	S )PythonEvaluationSuitezpythoneval.testzpythoneval-asyncio.testtestcaser   returnNonec                 C  s   t |tj| jjd d S )Nz.mypy_cache)test_python_evaluationospathjoin	cache_dirname)selfr    r   o/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/test/testpythoneval.pyrun_case%   s   zPythonEvaluationSuite.run_caseN)r   r   r   r   )__name__
__module____qualname__filesr   r   r   r   r   r   r   r   !   s    r   r   r   r   strr   r   c                 C  s  | j dus	J dg d}t}|ddttt  tdd| j	tj
}|r5||d  d	| j d
 }tjt|}|| t|ddd}| j	D ]
}|| d qSW d   n1 shw   Y  |d|  g }	t|\}
}}|
|  D ]/}|ttj r|	|tttj d d q|ttj td }|	|d q|dkrtj|d|gtdd}|	t|j|j t | t!|	D ]\}}tjjd tjj |v r|tjjd |	|< qt"t#| |	d| j$ d| j% d dS )z~Runs Mypy in a subprocess.

    If this passes without errors, executes the script again with a given Python
    version.
    Nztest was not properly set up)z--show-tracebackz--no-strict-optionalz--no-silence-site-packagesz--no-error-summaryz--python-version=.z# flags: (.*)$
   _.pywutf8)encodingz--cache-dir=z
/r   z-WignoreT)cwdcapture_outputtypeshedzInvalid output (z, line ))&old_cwdpython3_pathappendr   mapr   r   researchinput	MULTILINEextendgroupsplitr   r   r   r   openwriter   run
splitlines
startswithseplenrstripreplace
subprocessr
   stdoutstderrremove	enumerater	   adapt_outputfileline)r   r   mypy_cmdlineinterpretermprogramprogram_pathrF   soutputouterr
returncoderG   procir   r   r   r   )   sH   

$
r   	list[str]c                   s"   d| j  d   fdd| jD S )z<Translates the generic _program.py into the actual filename.r!   r"   c                   s   g | ]}t  |qS r   )
program_resub).0rG   rK   r   r   
<listcomp>e   s    z adapt_output.<locals>.<listcomp>)r   rN   )r   r   rX   r   rE   b   s   rE   )r   r   r   r   r   r   )r   r   r   rT   )__doc__
__future__r   r   os.pathr0   r@   systempfiler   mypyr   mypy.defaultsr   mypy.test.configr   mypy.test.datar   r   mypy.test.helpersr	   r
   
executabler-   compilerU   r   r   rE   r   r   r   r   <module>   s$    

9