
    1Vh                        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                  j!                  ej                  j#                  ej                  j%                  ej&                        d	            Zd
 Z G d de      Z G d d e
eej0                              Zd Zedk(  r ej8                          yy)z3Tests for generating code from a non-annotated ast.    )absolute_import)division)print_functionN)with_metaclass)codegen)
test_utilsz../testdatac                     t        | d      5 }	 t        j                  |j                                	 d d d        y# t        $ r Y d d d        yw xY w# 1 sw Y   yxY w)NrFT)openastparsereadSyntaxError)filepathfs     G/home/dcms/DCMS/lib/python3.12/site-packages/pasta/base/codegen_test.py_is_syntax_validr   "   s]    Hc a	ii
 
  	 
 
s&   A#<	AAAAAc                       e Zd Zd Zy)AutoFormatTestMetac                    d }d}t         j                  j                  t        d      }t        j                  |      D ]t  \  }}}	|	D ]i  }
|
j                  d      st         j                  j                  ||
      } t        j                  t        |       d       ||            |||
d d z   <   k v t        j                  | |||      S )Nc                       fd}|S )Nc                     t        d      5 }|j                         }d d d        t        j                        }t	        j
                  |      }| j                  ||       y # 1 sw Y   FxY w)Nr
   )r   r   r   r   r   to_strassertMultiLineEqual)selfhandlesrctauto_formatted
input_files        r   testzLAutoFormatTestMeta.__new__.<locals>.auto_format_test_generator.<locals>.test0   sZ    *c" 	f#	IIcN *!!#~6		 	s   A$$A- )r    r!   s   ` r   auto_format_test_generatorz>AutoFormatTestMeta.__new__.<locals>.auto_format_test_generator/   s    7 k    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_paths               r   r0   zAutoFormatTestMeta.__new__-   s     -ww||L)4HWWX. 7E 7(U#ggll7H5);(//"9--C; +95;7)&#26
777 <<T5)44r$   N)__name__
__module____qualname__r0   r"   r$   r   r   r   +   s    5r$   r   c                   |    e Zd ZdZd Z ej                  d      d        Z ej                  d      d        Zd Z	y)	AutoFormatTestz:Tests that code without formatting info is printed neatly.c                 |    d}t        j                  |      }| j                  |t        j                  |             y )Nz1from a import b
import c, d
from ..e import f, g
r   r   assertEqualpastadumpr   r   r   s      r   test_importszAutoFormatTest.test_importsI   s,    
@C		#AS%**Q-(r$   	exec_nodec                 |    d}t        j                  |      }| j                  dt        j                  |             y )Nzexec foo in barzexec(foo, bar)
rB   rF   s      r   test_exec_node_defaultz%AutoFormatTest.test_exec_node_defaultN   s-    
C		#A'A7r$   
bytes_nodec                 |    d}t        j                  |      }| j                  dt        j                  |             y )Nzb'foo'zb'foo'
rB   rF   s      r   
test_byteszAutoFormatTest.test_bytesT   s,    
C		#AZA/r$   c                    dD ]  }d|z   dz   }t        j                  |      }|j                  j                  t	        j                  d      j                         | j                  t        j                  |      |dz   |z   dz           y )N)z  z    	z	def a():
zb
z
def c(): dz	def c():
zd
)rD   r   bodyextendr   rC   r   r   )r   indentr   r   s       r   test_default_indentationz'AutoFormatTest.test_default_indentationZ   sx    & <& 5(c
++c
affmmCIIl+001
w~~a(\)F2U:<	<r$   N)
r<   r=   r>   __doc__rG   r   requires_featuresrJ   rM   rS   r"   r$   r   r@   r@   F   sQ    B)
  :,8 -8
  :-0 .0
<r$   r@   c                  ~    t        j                         } | j                  t        j                  t                     | S )N)r-   	TestSuiteaddTests	makeSuiter@   )results    r   suiter[   c   s,    &//($$^45	-r$   __main__)rT   
__future__r   r   r   r   os.pathr'   r-   sixr   rD   
pasta.baser   r   r(   realpathr)   dirname__file__r*   r   r/   r   TestCaser@   r[   r<   mainr"   r$   r   <module>rf      s    9 '  % 
      !wwGGLL0-@B5 56<^$6
8K8KL <: z(--/ r$   