o
    2h                     @   s   d Z ddlmZ ddlm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ZddlmZ ddlmZ ejejejejd	Zd
d ZG dd deZG dd de
eejZdd Zedkrle  dS dS )z3Tests for generating code from a non-annotated ast.    )absolute_import)division)print_functionN)with_metaclass)codegen)
test_utilsz../testdatac              	   C   sd   t | d#}z	t|  W n ty   Y W d    dS w W d    dS 1 s+w   Y  dS )NrFT)openastparsereadSyntaxError)filepathf r   R/var/www/html/chatgem/venv/lib/python3.10/site-packages/pasta/base/codegen_test.py_is_syntax_valid"   s   
r   c                   @   s   e Zd Zdd ZdS )AutoFormatTestMetac                 C   s   dd }d}t jtd}t |D ]+\}}}	|	D ]#}
|
dr<t j||
}tt| d|||||
d d  < qqt	
| |||S )Nc                    s    fdd}|S )Nc                    sV   t  d}| }W d    n1 sw   Y  t|}t|}| || d S )Nr   )r	   r   r
   r   r   to_strassertMultiLineEqual)selfhandlesrctauto_formatted
input_filer   r   test0   s   


zLAutoFormatTestMeta.__new__.<locals>.auto_format_test_generator.<locals>.testr   )r   r   r   r   r   auto_format_test_generator/   s   z>AutoFormatTestMeta.__new__.<locals>.auto_format_test_generatortest_auto_format_r   z.inz3Test contains syntax not supported by this version.)ospathjoinTESTDATA_DIRwalkendswithunittestskipIfr   type__new__)mcsnamebases	inst_dictr   test_method_prefixdata_dirdirpath_filesfilename	full_pathr   r   r   r*   -   s    

zAutoFormatTestMeta.__new__N)__name__
__module____qualname__r*   r   r   r   r   r   +   s    r   c                   @   sD   e Zd ZdZdd Zeddd Zeddd	 Zd
d Z	dS )AutoFormatTestz:Tests that code without formatting info is printed neatly.c                 C   s$   d}t |}| |t| d S )Nz1from a import b
import c, d
from ..e import f, g
r
   r   assertEqualpastadumpr   r   r   r   r   r   test_importsI   s   
zAutoFormatTest.test_imports	exec_nodec                 C   $   d}t |}| dt| d S )Nzexec foo in barzexec(foo, bar)
r:   r>   r   r   r   test_exec_node_defaultN      
z%AutoFormatTest.test_exec_node_default
bytes_nodec                 C   rA   )Nzb'foo'zb'foo'
r:   r>   r   r   r   
test_bytesT   rC   zAutoFormatTest.test_bytesc                 C   sV   dD ]&}d| d }t |}|jtdj | t||d | d  qd S )N)z  z    	z	def a():
zb
z
def c(): dz	def c():
zd
)r<   r   bodyextendr
   r;   r   r   )r   indentr   r   r   r   r   test_default_indentationZ   s   
z'AutoFormatTest.test_default_indentationN)
r6   r7   r8   __doc__r?   r   requires_featuresrB   rE   rJ   r   r   r   r   r9   F   s    

r9   c                  C   s   t  } | t t | S )N)r'   	TestSuiteaddTests	makeSuiter9   )resultr   r   r   suitec   s   rQ   __main__)rK   
__future__r   r   r   r
   os.pathr!   r'   sixr   r<   
pasta.baser   r   r"   realpathr#   dirname__file__r$   r   r)   r   TestCaser9   rQ   r6   mainr   r   r   r   <module>   s*   	