B
    v9a                 @   s   d Z ddlmZ ddlZddlmZ ddlZddlm	Z	 ddl
mZ dddhZd	hZeeB ZG d
d dejZG dd dejZG dd dejZedkrejdd dS )z%Test macosx, coverage 45% on Windows.    )macosxN)requires)FileListcarboncocoaxquartzotherc               @   s0   e Zd ZdZedd Zedd Zdd ZdS )	InitTktypeTestzTest _init_tk_type.c             C   s(   t d t | _| j  tj| _d S )Ngui)r   tkTkrootwithdrawr   platformorig_platform)cls r   !/usr/lib/python3.7/test_macosx.py
setUpClass   s    

zInitTktypeTest.setUpClassc             C   s$   | j   | j   | ` | jt_d S )N)r   update_idletasksdestroyr   r   r   )r   r   r   r   tearDownClass   s    

zInitTktypeTest.tearDownClassc          
   C   s`   xZdt fdtffD ]F\}}| j|d, |t_tjdk t  | tj| W dQ R X qW dS )z<Test that _init_tk_type sets _tk_type according to platform.darwinr   )r   N)alltypesnontypessubTestr   r   _tk_typeZ_init_tk_typeZassertIn)selfr   typesr   r   r   test_init_sets_tktype    s    
z$InitTktypeTest.test_init_sets_tktypeN)__name__
__module____qualname____doc__classmethodr   r   r   r   r   r   r   r	      s   r	   c               @   sN   e Zd ZdZejdfejdfejdfejdffZ	e
ddd Zd	d
 ZdS )IsTypeTkTestz*Test each of the four isTypeTk predecates.)r   r   r   r   r   zidlelib.macosx._init_tk_typec          
   C   sP   dt _xD| jD ]:\}}| j|d  |  | |j |  W dQ R X qW dS )zBTest that each isTypeTk calls _init_tk_type when _tk_type is None.N)func)r   r   isfuncsr   
assertTruecalled
reset_mock)r   Zmockinitr&   whentruer   r   r   test_is_calls_init2   s    zIsTypeTkTest.test_is_calls_initc             C   sb   x\| j D ]R\}}xHtD ]@}| j|||d& |t_||kr@| jn| j|  W dQ R X qW qW dS )z,Test that each isTypeTk return correct bool.)r&   r+   tktypeN)r'   r   r   r   r   r(   ZassertFalse)r   r&   r+   r-   r   r   r   test_isfuncs<   s    
zIsTypeTkTest.test_isfuncsN)r    r!   r"   r#   r   ZisAquaTkZ
isCarbonTkZ	isCocoaTkZ	isXQuartzr'   mockpatchr,   r.   r   r   r   r   r%   *   s   
r%   c               @   s:   e Zd ZdZedd Zedd Zeddd Z	d	S )
	SetupTestzTest setupApp.c                s4   t d t | _| j   fdd  | j_d S )Nr
   c                s   d S )Nr   )Ztkpathr&   )cmdr   r   r2   N   s    z!SetupTest.setUpClass.<locals>.cmd)r   r   r   r   r   Zcreatecommand)r   r   )r2   r   r   I   s
    

zSetupTest.setUpClassc             C   s   | j   | j   | ` d S )N)r   r   r   )r   r   r   r   r   S   s    

zSetupTest.tearDownClasszidlelib.macosx.overrideRootMenuc          
   C   sf   | j }t|}xRtD ]J}| j|d4 |t_t|| |dkrL| |j |	  W dQ R X qW dS )z/Call setupApp with each possible graphics type.)r-   )r   r   N)
r   r   r   r   r   r   ZsetupAppr(   r)   r*   )r   ZoverrideRootMenur   flistr-   r   r   r   test_setupappY   s    
zSetupTest.test_setupappN)
r    r!   r"   r#   r$   r   r   r/   r0   r4   r   r   r   r   r1   F   s   
r1   __main__   )	verbosity)r#   Zidlelibr   ZunittestZtest.supportr   Ztkinterr   Zunittest.mockr/   Zidlelib.filelistr   Zmactypesr   r   ZTestCaser	   r%   r1   r    mainr   r   r   r   <module>   s   
!