B
    '(b                 @   s   d 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Zddlm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mZ dd	lmZmZ dd
lmZ ddlmZ ejZedZG dd deZeeddddZ eee 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.
    N)PIPE)TemporaryDirectory)List)PYTHON3_VERSION)test_temp_dir)DataDrivenTestCase	DataSuite)assert_string_arrays_equalsplit_lines)try_find_python2_interpreter)apiz\b_program.py\bc               @   s,   e Zd ZdddgZe ZeddddZdS )PythonEvaluationSuitezpythoneval.testzpython2eval.testzpythoneval-asyncio.testN)testcasereturnc             C   s   t |tj| jjd d S )Nz.mypy_cache)test_python_evaluationospathjoin	cache_dirname)selfr    r   G/home/dcms/DCMS/lib/python3.7/site-packages/mypy/test/testpythoneval.pyrun_case+   s    zPythonEvaluationSuite.run_case)__name__
__module____qualname__filesr   r   r   r   r   r   r   r   r   %   s
   r   )r   r   r   c          	   C   sH  | j dk	stdddddg}| j d}|rX|d t }|dkrxt  dS n t	}|d	d

ttt  tdd
| jtj}|r||d  d| j d }tj
t|}|| t|ddd&}x| jD ]}	||	 d qW W dQ R X |d|  g }
t|\}}}xr||  D ]b}|ttj rt|
|tttj d  d n&|!ttj td }|
| d q:W |dkrt"j|d|gtt#t#d}|
t$|j%|j& t'| xFt(|
D ]:\}}tjjd tjj |kr|tjjd |
|< qW t)t*| |
d+| j,| j- 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 upz--show-tracebackz--no-strict-optionalz--no-silence-site-packagesz--no-error-summaryZpython2z--py2z--python-version=.z# flags: (.*)$
   _z.pywutf8)encodingz--cache-dir=z
/r   z-Wignore)cwdstdoutstderrZtypeshedzInvalid output ({}, line {})).Zold_cwdAssertionErrorr   lowerendswithappendr   pytestskippython3_pathr   mapstrr   researchinput	MULTILINEextendgroupsplitr   r   r   openwriter   run
splitlines
startswithseplenrstripreplace
subprocessr   r
   r'   r(   remove	enumerater	   adapt_outputformatfileline)r   r   Zmypy_cmdlineZpy2interpretermprogramZprogram_pathrH   soutputouterr
returncoderI   procir   r   r   r   /   sT    

$


r   )r   r   c                s"   d| j  d   fdd| jD S )z<Translates the generic _program.py into the actual filename.r!   z.pyc                s   g | ]}t  |qS r   )
program_resub).0rI   )rL   r   r   
<listcomp>t   s    z adapt_output.<locals>.<listcomp>)r   rN   )r   r   )rL   r   rF   q   s    rF   )"__doc__r   os.pathr3   rC   r   systempfiler   r.   typingr   Zmypy.defaultsr   Zmypy.test.configr   Zmypy.test.datar   r   Zmypy.test.helpersr	   r
   Z	mypy.utilr   Zmypyr   
executabler0   compilerT   r   r2   r   rF   r   r   r   r   <module>   s(   

B