o
    2g                     @  sr   d Z ddlm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	 d	eZd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                   @  s   e Zd ZdgZd	ddZdS )
OutputJSONsuitezoutputjson.testtestcaser   returnNonec                 C  s   t | d S )N)test_output_json)selfr	    r   L/home/garg/my-data/venv/lib/python3.10/site-packages/mypy/test/testoutput.pyrun_case   s   zOutputJSONsuite.run_caseNr	   r   r
   r   )__name__
__module____qualname__filesr   r   r   r   r   r      s    r   r	   r   r
   r   c                   sB  dg}| ddttt  tjtd}| | t|ddd}| j	D ]
}|
| d q(W d	   n1 s=w   Y  g }t|\}}}|| d D ]$}	|	ttj rq| |	tttj d	 d
 qU| |	d
 qU|dkr| d t| tjdd  fdd|D }
|
| jksJ d	S )zNRuns Mypy in a subprocess, and ensures that `--output=json` works as intended.z--output=jsonz--python-version=.mainwutf8)encoding
Nz
   z!!! Mypy crashed !!!\z\\c                   s   g | ]
}| t  d qS ) )replacer   ).0linejson_os_separatorr   r   
<listcomp>8   s    z$test_output_json.<locals>.<listcomp>)appendjoinmapstrr   ospathr   openinputwriter   runrstrip
splitlines
startswithseplenremover   output)r	   mypy_cmdlineprogram_pathfilesr5   outerr
returncoder!   normalized_outputr   r"   r   r      s*   

$

r   r   )__doc__
__future__r   r)   os.pathmypyr   mypy.defaultsr   mypy.test.configr   mypy.test.datar   r   r   r   r   r   r   r   <module>   s    