o
    7f                     @  s   d 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 dd	lmZ dd
lmZmZ ddlmZmZmZ ddlmZ G dd deZdddZdZG dd deZdddZdS )zTests for the mypy parser.    )annotationsN)skip)defaults)parse_mypy_comments)CompileErrorErrors)Options)parse)DataDrivenTestCase	DataSuite)assert_string_arrays_equalfind_test_filesparse_options)get_mypy_commentsc                   @  s@   e Zd ZdZdZeddgdZejdk re	d dddZ
dS )ParserSuiteT.zparse*.testparse-errors.test)patternexclude   
   zparse-python310.testtestcaser
   returnNonec                 C     t | d S N)test_parserselfr    r    L/home/ertert/spirit/venv/lib/python3.10/site-packages/mypy/test/testparse.pyrun_case      zParserSuite.run_caseNr   r
   r   r   )__name__
__module____qualname__required_out_section	base_pathr   filessysversion_inforemover"   r    r    r    r!   r      s    

r   r   r
   r   r   c           	   
   C  s   t  }d|_d|_| jdrd|_ntj|_d| j	}t
|}t||\}}||}ztt|dddt||dd}||d}W n ty[ } z	|j}W Y d	}~nd	}~ww t| j|d
| j d| j d d	S )zdPerform a single parser test case.

    The argument contains the description of the test case.
    Tzpython310.testr   
asciimain__main__)fnammoduleerrorsoptionsraise_on_errorNzInvalid parser output (, line ))r   force_uppercase_builtinshide_error_codesfileendswithpython_versionr   PYTHON3_VERSIONjoininputr   r   apply_changesr	   bytesr   str_with_optionssplitr   messagesr   outputline)	r   r5   sourcecommentschanges_naer    r    r!   r      s6   
r   r;   c                   @  s$   e Zd ZdZdZdgZddd	Zd
S )ParseErrorSuiteTr   r   r   r
   r   r   c                 C  r   r   )test_parse_errorr   r    r    r!   r"   O   r#   zParseErrorSuite.run_caseNr$   )r%   r&   r'   r(   r)   r*   r"   r    r    r    r!   rO   J   s
    rO   c                 C  s   z.t d| j| d}|jtjd d krt  ttd| jdt	dt
||dd td ty^ } z$|jd urB|jdksBJ t| j|jd	| j d
| j d W Y d }~d S d }~ww )Nr.   r      zutf-8r1   T)r4   r5   r6   zNo errors reportedzInvalid compiler output (r7   r8   )r   r?   r@   r=   r+   r,   r   r	   rB   INPUT_FILE_NAMEr   AssertionErrorr   module_with_blockerr   rF   rE   r;   rG   )r   r5   rN   r    r    r!   rP   S   s.   
rP   r$   )__doc__
__future__r   r+   pytestr   mypyr   mypy.config_parserr   mypy.errorsr   r   mypy.optionsr   
mypy.parser	   mypy.test.datar
   r   mypy.test.helpersr   r   r   	mypy.utilr   r   r   rR   rO   rP   r    r    r    r!   <module>   s"    
(	