
    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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j        d
          Z G d de          ZddZ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                  2    e Zd ZddgZ e            Zd	dZdS )
PythonEvaluationSuitezpythoneval.testzpythoneval-asyncio.testtestcaser   returnNonec                v    t          |t          j                            | j        j        d                     d S )Nz.mypy_cache)test_python_evaluationospathjoin	cache_dirname)selfr   s     X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/test/testpythoneval.pyrun_casezPythonEvaluationSuite.run_case%   s-    xdn6I=)Y)YZZZZZ    N)r   r   r   r   )__name__
__module____qualname__filesr   r   r    r   r   r   r   !   sG         9:E""$$I[ [ [ [ [ [r   r   r   r   r   strr   r   c           	     x   | j         
J d            g d}t          }|                    dd                    t	          t
          t                                          t          j        dd                    | j	                  t          j
                  }|r|                    d                                          }|D ]}|                    d          rx|                    d	          d         }|                    d          \  }}	t          |          t          |	          ft          j        j        t          j        j        fk    r dS |                    |           d
| j        z   dz   }
t*          j                            t.          |
          }|                    |           t1          |dd          5 }| j	        D ]}|                    | d           	 ddd           n# 1 swxY w Y   |                    d|            g }t5          j        |          \  }}}||z                                   D ]}|                    t.          t*          j        z             rP|                    |t=          t.          t*          j        z             d                             d                     y|                     t.          t*          j        z   t.          dz             }|                    |                    d                     |dk    r| j!        s|                    d           |dk    rN|sLtE          j        |d|
gt.          d          }|                    tG          |j$        |j%                             t+          j&        |           tO          |          D ]Z\  }}t*          j        j        dz   t*          j        j        z   |v r-|                    t*          j        j                  d         ||<   [tQ          tS          |           |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-silence-site-packagesz--no-error-summaryz--hide-error-codesz--allow-empty-bodiesz--force-uppercase-builtinsz
--test-envz--python-version=.z# flags: (.*)$
   =_.pywutf8)encodingz--cache-dir=z
/z!!! Mypy crashed !!!r   z-WignoreT)cwdcapture_outputtypeshedzInvalid output (z, line )),old_cwdpython3_pathappendr   mapr!   r   researchinput	MULTILINEgroupsplit
startswithintsysversion_infomajorminorextendr   r   r   r   openwriter   run
splitlinesseplenrstripreplaceoutput
subprocessr   stdoutstderrremove	enumerater
   adapt_outputfileline)r   r   mypy_cmdlineinterpretermadditional_flagsflagtargeted_python_versiontargeted_majortargeted_minorprogramprogram_pathrR   srK   outerr
returncoderS   procis                        r   r   r   )   sD    '')G'''  L KQCHHSo5N5N,O,OQQRRR
	"DIIhn$=$=r|LLA .771::++--$ 	 	D233 *.**S//!*<'1H1N1Ns1S1S.''^)<)<=$*$*A   FF,--- HM!E)G7<<w77L%%%	lC&	1	1	1 !T 	! 	!AJJ!xxx    	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 2y22333F7<00Cjs&&(( / /??=26122 	/MM$s=26#9::<<=DDVLLMMMM << 68KLLDMM$++f--....A~~ho~ 	,---Qv~*g.MRV
 
 
 	k$+t{;;<<<IlV$$ 4 447;#bgk1T99

27;//3F1IX(a8=(a(aQYQ^(a(a(a    s   #G11G58G5	list[str]c                D    d| j         z   dz   fd| j        D             S )z<Translates the generic _program.py into the actual filename.r'   r(   c                F    g | ]}t                               |          S r    )
program_resub).0rS   r\   s     r   
<listcomp>z adapt_output.<locals>.<listcomp>u   s'    FFFdJNN7D))FFFr   )r   rK   )r   r\   s    @r   rQ   rQ   r   s0    HM!E)GFFFFhoFFFFr   )r   r   r   r!   r   r   )r   r   r   rd   )__doc__
__future__r   r   os.pathr6   rL   r>   tempfiler   mypyr   mypy.defaultsr   mypy.test.configr   mypy.test.datar   r	   mypy.test.helpersr
   r   
executabler3   compilerg   r   r   rQ   r    r   r   <module>rv      sU  
 
 # " " " " " 				  				     



 ' ' ' ' ' '       ) ) ) ) ) ) * * * * * * 8 8 8 8 8 8 8 8 E E E E E E E E ~RZ*++
[ [ [ [ [I [ [ [F F F FRG G G G G Gr   