
    \j                        d Z ddlm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mZ  G d d	e          ZddZdS )zTest cases for `--output=json`.

These cannot be run by the usual unit test runner because of the backslashes in
the output, which get normalized to forward slashes by the test suite on Windows.
    )annotationsN)api)PYTHON3_VERSION)test_temp_dir)DataDrivenTestCase	DataSuitec                      e Zd ZdgZddZdS )	OutputJSONsuitezoutputjson.testtestcaser   returnNonec                $    t          |           d S )N)test_output_json)selfr   s     X/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/mypy/test/testoutput.pyrun_casezOutputJSONsuite.run_case   s    """""    Nr   r   r   r   )__name__
__module____qualname__filesr    r   r   r
   r
      s0        E# # # # # #r   r
   r   r   r   r   c           	        d                     | j                  }t          j        d|t          j                  }|(|                    d                                          }ndg}|                    dd                     t          t          t                                          t          j                             t          d	          }|                    |           t          |d
d          5 }| j        D ]}|                    | d           	 ddd           n# 1 swxY w Y   g }t!          j        |          \  }}	}
||	z                       d                                          D ]}|                    t          t          j        z             rP|                    |t-          t          t          j        z             d                             d                     y|                    |                    d                     |
dk    r|                    d           t          j        |           t          j                            dd          fd|D             }|| j        k    sJ dS )zNRuns Mypy in a subprocess, and ensures that `--output=json` works as intended.
z# flags: (.*)$)flagsN   z--output=jsonz--python-version=.mainwutf8)encodingz
z!!! Mypy crashed !!!\z\\c                L    g | ] }|                     t          z   d           !S ) )replacer   ).0linejson_os_separators     r   
<listcomp>z$test_output_json.<locals>.<listcomp>>   s.    ```QUm6G&GLL```r   )joininputresearch	MULTILINEgroupsplitappendmapstrr   ospathr   openwriter   runrstrip
splitlines
startswithseplenremover&   output)r   program_textflags_matchmypy_cmdlineprogram_pathfilesr@   outerr
returncoder(   normalized_outputr)   s                @r   r   r      s   99X^,,L),l",OOOK"((++1133'(QCHHSo5N5N,O,OQQRRR 7<<v66L%%%	lC&	1	1	1 !T 	! 	!AJJ!xxx    	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! F7<00Cjs""4((3355 / /??=26122 	/MM$s=26#9::<<=DDVLLMMMMMM$++f--....A~~,--- Il tV44````Y_```//////s   9#D))D-0D-r   )__doc__
__future__r   r5   os.pathr-   mypyr   mypy.defaultsr   mypy.test.configr   mypy.test.datar   r   r
   r   r   r   r   <module>rR      s     # " " " " " 				  				       ) ) ) ) ) ) * * * * * * 8 8 8 8 8 8 8 8# # # # #i # # #&0 &0 &0 &0 &0 &0r   