B
    '(b                 @   s   d Z ddl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 dd	lmZ G d
d deZe
ddddZdZG dd deZe
ddddZdS )zTests for the mypy parser.    N)skip)defaults)assert_string_arrays_equalparse_options)DataDrivenTestCase	DataSuite)parse)CompileError)Optionsc               @   s@   e Zd ZdZdZddgZejdkr,ed e	ddd	d
Z
dS )ParserSuiteT.z
parse.testzparse-python2.test)   
   zparse-python310.testN)testcasereturnc             C   s   t | d S )N)test_parser)selfr    r   B/home/dcms/DCMS/lib/python3.7/site-packages/mypy/test/testparse.pyrun_case   s    zParserSuite.run_case)__name__
__module____qualname__required_out_section	base_pathfilessysversion_infoappendr   r   r   r   r   r   r      s   

r   )r   r   c          
   C   s   t  }| jdrtj|_n| jdr0d|_ntj|_y2ttd	| j
dddd|d	}t|d}W n( tk
r } z
|j}W dd}~X Y nX t| j|d
| j| j dS )zdPerform a single parser test case.

    The argument contains the description of the test case.
    zpython2.testzpython310.test)r   r   
asciimain__main__N)Zfnammoduleerrorsoptionsz#Invalid parser output ({}, line {}))r
   fileendswithr   ZPYTHON2_VERSIONpython_versionZPYTHON3_VERSIONr   bytesjoininputstrsplitr	   messagesr   outputformatline)r   r%   naer   r   r   r      s$    
r   r&   c               @   s*   e Zd ZdZdZdgZeddddZdS )ParseErrorSuiteTr   zparse-errors.testN)r   r   c             C   s   t | d S )N)test_parse_error)r   r   r   r   r   r   B   s    zParseErrorSuite.run_case)r   r   r   r   r   r   r   r   r   r   r   r   r5   =   s   r5   c             C   s   yXt d| j| d}|jtjd d kr0t  ttd| jdt	dd | t
dW n\ tk
r } z>|jd k	r|jdkst
t| j|jd| j d| j d	 W d d }~X Y nX d S )
Nr   r      zutf-8r"   zNo errors reportedzInvalid compiler output (z, line ))r   r*   r+   r(   r   r   r   r   r)   INPUT_FILE_NAMEAssertionErrorr	   Zmodule_with_blockerr   r/   r.   r&   r1   )r   r%   r4   r   r   r   r6   F   s    
r6   )__doc__r   Zpytestr   Zmypyr   Zmypy.test.helpersr   r   Zmypy.test.datar   r   Z
mypy.parser   Zmypy.errorsr	   Zmypy.optionsr
   r   r   r9   r5   r6   r   r   r   r   <module>   s   	