ó
æŸ?`c           @   sÑ   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z e j j e j j	 e
 ƒ ƒ Z d a d „  Z d „  Z e e d d „ Z e e d d „ Z e d k rÍ d g e j _ e j j e ƒ  Œ  n  d S(	   sß   
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.
iÿÿÿÿNc    
         sF  t  d k r*t a  t j d k rê d d l m }  m ‰  m } m	 } d d l
 m } |  j | d ƒ ƒ } | j ƒ  d k rƒ d a  q'd | f ‡  f d	 †  ƒ  Y} | ƒ  } | | ƒ } | j | ƒ d k  sÞ | j | ƒ d k  r'd
 a  q'q*d d l } y | j ƒ  Wq*| j k
 r&}	 d |	 a  q*Xn  t  rBt j t  ƒ ‚ n  d S(   s)   Check that Tk is installed and available.t   darwiniÿÿÿÿ(   t   cdllt   c_intt   pointert	   Structure(   t   find_libraryt   ApplicationServicesi    s&   cannot run without OS X window managert   ProcessSerialNumberc              s    e  Z d  ˆ  f d ˆ  f g Z RS(   t   highLongOfPSNt   lowLongOfPSN(   t   __name__t
   __module__t   _fields_(    (   R   (    s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyR   (   s   	s#   cannot run without OS X gui processNs   tk not available: %s(   t   _tk_unavailablet   Nonet   Falset   syst   platformt   ctypesR   R   R   R   t   ctypes.utilR   t   LoadLibraryt   CGMainDisplayIDt   GetCurrentProcesst   SetFrontProcesst   Tkintert   Buttont   TclErrort   unittestt   SkipTest(
   R   R   R   R   t   app_servicesR   t   psnt   psn_pR   t   msg(    (   R   s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyt   check_tk_availability   s,    "		c         C   s.   x' t  j |  ƒ D] } | d k r t Sq Wt S(   Ns   __init__.pys   __init__.pycs
   __init.pyo(   s   __init__.pys   __init__.pycs
   __init.pyo(   t   ost   listdirt   TrueR   (   t   patht   name(    (    s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyt
   is_package<   s    c   	   	   #   s-  d ‰  x t  j |  ƒ D]\ } } } x4 t | ƒ D]& } | d d k r2 | j | ƒ q2 q2 Wt | ƒ r | r | t |  ƒ t t  j ƒ j d d ƒ } | r¯ | | k r¯ q n  t ‡  f d †  | ƒ } x[ | D]P } y$ t	 j
 d | t ˆ  ƒ  | ƒ VWqÎ t j j k
 r| r‚  qqÎ XqÎ Wq q Wd S(   sê   This 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 colleted.
    s   .pyi    t   .t   /c            s   |  j  d ƒ o |  j ˆ  ƒ S(   Nt   test_(   t
   startswitht   endswith(   t   x(   t   py_ext(    s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyt   <lambda>V   s    s   .%sN(   R"   t   walkt   listt   removeR'   t   lent   sept   replacet   filtert	   importlibt   import_modulet   testt   test_supportt   ResourceDenied(	   t   basepatht   guit   packagest   dirpatht   dirnamest	   filenamest   dirnamet   pkg_nameR&   (    (   R.   s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyt   get_tests_modulesB   s&    )	c         c   s‰   g  } |  r | j  d ƒ n  | r2 | j  d ƒ n  xP t d | d | ƒ D]9 } x0 | D]( } x t | | d ƒ D] } | Vqn WqU WqH Wd S(   s   Yield 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.t   tests_noguit	   tests_guiR=   R>   N(    (   t   appendRD   t   getattr(   t   textR=   R>   t   attrst   modulet   attrR9   (    (    s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyt	   get_testsa   s    t   __main__R=   (   t   __doc__R"   R   R   R7   t   test.test_supportR9   R%   t   abspathRB   t   __file__t   this_dir_pathR   R   R!   R'   R$   RD   RM   R
   R:   t   use_resourcest   run_unittest(    (    (    s.   /usr/lib64/python2.7/lib-tk/test/runtktests.pyt   <module>   s   	)	