o
    JAfœ  ã                   @   sè   d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z ej e¡Zej ej ed¡¡Zej edd¡Ze e¡Ze e¡Zejd= ejeejd	Z
ejeejd	Zd
d„ Zddd„Zdd„ Zddd„Zdd„ Zej Z dS )z Support code for test_*.py filesé    N©Údedent)ÚpytreeÚrefactor)Údriverz..zGrammar.txtÚprint)Úconvertc                 C   s   t jt| ƒddS )NT)Údebug)r   Úparse_stringÚreformat©Ústring© r   ú,/usr/lib/python3.10/lib2to3/tests/support.pyr
      s   r
   c                 C   s,   |d u rt  ¡  | ¡}t jdd |¡ d S )Né   )Ú	verbosity)ÚunittestZ
TestLoaderZloadTestsFromModuleZTextTestRunnerÚrun)Ztest_modZtestsr   r   r   Úrun_all_tests   s   r   c                 C   s   t | ƒd S )Nz

r   r   r   r   r   r   "   s   r   Úlib2to3c                    sB   |dur‡ fdd„|D ƒ}nt  ˆ d ¡}|pi }t j||ddS )a
  
    A convenience function for creating a RefactoringTool for tests.

    fixers is a list of fixers for the RefactoringTool to use. By default
    "lib2to3.fixes.*" is used. options is an optional dictionary of options to
    be passed to the RefactoringTool.
    Nc                    s   g | ]}ˆ d  | ‘qS )z.fixes.fix_r   )Ú.0Zfix©Ú	fixer_pkgr   r   Ú
<listcomp>.   s    z"get_refactorer.<locals>.<listcomp>z.fixesT)Zexplicit)r   Zget_fixers_from_packageZRefactoringTool)r   ZfixersÚoptionsr   r   r   Úget_refactorer%   s
   r   c                  c   s@    t  t¡D ]\} }}|D ]}| d¡rt j | |¡V  qqd S )Nz.py)ÚosÚwalkÚproj_dirÚendswithÚpathÚjoin)ÚdirpathÚdirnamesÚ	filenamesÚfilenamer   r   r   Úall_project_files4   s   €
€þÿr&   )NN)r   NN)!Ú__doc__r   r   Zos.pathÚtextwrapr   r   r   r   Zlib2to3.pgen2r   Zpgen2_driverr    ÚdirnameÚ__file__Ztest_dirÚnormpathr!   r   Zgrammar_pathZload_grammarZgrammarZgrammar_no_print_statementÚkeywordsZDriverr   Zdriver_no_print_statementr
   r   r   r   r&   ZTestCaser   r   r   r   Ú<module>   s0    

þ


