B
    u9a                 @   sl   d Z ddlZddlZddlZejejeZ	dd Z
e	ddfddZddd	Zed
krhejje   dS )z
Use this module to get and run all tk tests.

tkinter tests should live in a package inside the directory where this file
lives, like test_tkinter.
Extensions also should live in packages following the same rule as above.
    Nc             C   s$   xt | D ]}|dkrdS qW dS )N)z__init__.pyz__init__.pycTF)oslistdir)pathname r    /usr/lib/python3.7/runtktests.py
is_package   s    r   Tc       	   
   #   s   d xt | D ]\}}}x&t|D ]}|d dkr$|| q$W t|r|r|t| tt j d dd}|r~||kr~qt fdd|}xT|D ]L}y(t	
d||dt   f d	V  W q tjjk
r   |r܂ Y qX qW qW dS )
zThis will import and yield modules whose names start with test_
    and are inside packages found in the path starting at basepath.

    If packages is specified it should contain package names that
    want their tests collected.
    z.pyr   .N/c                s   |  do|  S )NZtest_)
startswithendswith)x)py_extr   r   <lambda>)       z#get_tests_modules.<locals>.<lambda>z.%s.%sztkinter.test)r   walklistremover   lensepreplacefilter	importlibimport_moduletestsupportZResourceDenied)	ZbasepathguipackagesdirpathZdirnames	filenamesdirnameZpkg_namer   r   )r   r   get_tests_modules   s(    "

r!   c             c   sd   g }| r| d |r | d x>t||dD ].}x(|D ] }xt||dD ]
}|V  qJW q8W q.W dS )zYield all the tests in the modules found by get_tests_modules.

    If nogui is True, only tests that do not require a GUI will be
    returned.Ztests_noguiZ	tests_gui)r   r   r   N)appendr!   getattr)textr   r   Zattrsmoduleattrr   r   r   r   	get_tests5   s    


r'   __main__)TTN)__doc__r   r   Ztest.supportr   r   abspathr    __file__Zthis_dir_pathr   r!   r'   __name__r   Zrun_unittestr   r   r   r   <module>   s    
