a
    ¦ˆcM  ã                   @   s¦   d Z ddlZddlmZ ddlmZmZmZ g ZG dd„ deƒZ	G dd„ deƒZ
G d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dejƒZdS )z! Tests for the static notifiers. é    N)Útrait_notifiers)ÚFloatÚ	HasTraitsÚListc                   @   s$   e Zd ZeZdd„ ZeZdd„ ZdS )ÚStaticNotifiers0c                   C   s   t  d¡ d S )NT)Úcalls_0Úappend© r	   r	   úe/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traits/tests/test_static_notifiers.pyÚ_ok_changed   s    zStaticNotifiers0._ok_changedc                   C   s   t dƒ‚d S ©NÚerror©Ú	Exceptionr	   r	   r	   r
   Ú_fail_changed   s    zStaticNotifiers0._fail_changedN©Ú__name__Ú
__module__Ú__qualname__r   Úokr   Úfailr   r	   r	   r	   r
   r      s   r   c                   @   s$   e Zd ZeZdd„ ZeZdd„ ZdS )ÚStaticNotifiers1c                 C   s    t | dƒsg | _| j d¡ d S )NÚcallsT©Úhasattrr   r   ©Úselfr	   r	   r
   r   $   s    
zStaticNotifiers1._ok_changedc                 C   s   t dƒ‚d S r   r   r   r	   r	   r
   r   +   s    zStaticNotifiers1._fail_changedNr   r	   r	   r	   r
   r   !   s   r   c                   @   s$   e Zd ZeZdd„ ZeZdd„ ZdS )ÚStaticNotifiers2c                 C   s    t | dƒsg | _| j |¡ d S ©Nr   r   ©r   Únewr	   r	   r
   r   2   s    
zStaticNotifiers2._ok_changedc                 C   s   t dƒ‚d S r   r   r   r	   r	   r
   r   9   s    zStaticNotifiers2._fail_changedNr   r	   r	   r	   r
   r   /   s   r   c                   @   s$   e Zd ZeZdd„ ZeZdd„ ZdS )ÚStaticNotifiers3c                 C   s$   t | dƒsg | _| j ||f¡ d S r   r   ©r   Úoldr    r	   r	   r
   r   @   s    
zStaticNotifiers3._ok_changedc                 C   s   t dƒ‚d S r   r   r"   r	   r	   r
   r   G   s    zStaticNotifiers3._fail_changedNr   r	   r	   r	   r
   r!   =   s   r!   c                   @   s$   e Zd ZeZdd„ ZeZdd„ ZdS )ÚStaticNotifiers4c                 C   s&   t | dƒsg | _| j |||f¡ d S r   r   ©r   Únamer#   r    r	   r	   r
   r   N   s    
zStaticNotifiers4._ok_changedc                 C   s   t dƒ‚d S r   r   r%   r	   r	   r
   r   U   s    zStaticNotifiers4._fail_changedNr   r	   r	   r	   r
   r$   K   s   r$   c                   @   s    e Zd Zeƒ Zeƒ Zdd„ ZdS )Ú_LeadingUnderscorec                 C   s   | j  |||f¡ d S ©N)r   r   r%   r	   r	   r
   Z__ok_changed]   s    z_LeadingUnderscore.__ok_changedN)r   r   r   r   Ú_okr   r   Z_LeadingUnderscore__ok_changedr	   r	   r	   r
   r'   Y   s   r'   c                   @   sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚTestNotifierszJ Tests for the static notifiers, and the "anytrait" static notifiers.
    c                 C   s   g | _ t | j¡ d S r(   )Ú
exceptionsr   Zpush_exception_handlerÚ_handle_exceptionr   r	   r	   r
   ÚsetUpe   s    zTestNotifiers.setUpc                 C   s   t  ¡  d S r(   )r   Zpop_exception_handlerr   r	   r	   r
   ÚtearDowni   s    zTestNotifiers.tearDownc                 C   s   | j  ||||f¡ d S r(   )r+   r   )r   Úobjr&   r#   r    r	   r	   r
   r,   l   s    zTestNotifiers._handle_exceptionc                 C   sJ   t  ¡  tdd�}d|_|  tt ƒd¡ d|_|  | j|dddfg¡ d S ©Né   ©r   é   é   r   r   )r   Úclearr   r   ÚassertEqualÚlenr   r+   ©r   r/   r	   r	   r
   Útest_static_notifiers_0o   s    
z%TestNotifiers.test_static_notifiers_0c                 C   sD   t dd�}d|_|  t|jƒd¡ d|_|  | j|dddfg¡ d S r0   )r   r   r6   r7   r   r   r+   r8   r	   r	   r
   Útest_static_notifiers_1y   s
    
z%TestNotifiers.test_static_notifiers_1c                 C   sD   t dd�}d|_|  |jddg¡ d|_|  | j|dddfg¡ d S r0   )r   r   r6   r   r   r+   r8   r	   r	   r
   Útest_static_notifiers_2�   s
    
z%TestNotifiers.test_static_notifiers_2c                 C   sD   t dd�}d|_|  |jddg¡ d|_|  | j|dddfg¡ d S )	Nr1   r2   r3   )r   r1   )r1   r3   r4   r   r   )r!   r   r6   r   r   r+   r8   r	   r	   r
   Útest_static_notifiers_3ˆ   s
    
z%TestNotifiers.test_static_notifiers_3c                 C   sD   t dd�}d|_|  |jddg¡ d|_|  | j|dddfg¡ d S )	Nr1   r2   r3   )r   r   r1   )r   r1   r3   r4   r   r   )r$   r   r6   r   r   r+   r8   r	   r	   r
   Útest_static_notifiers_4�   s
    
z%TestNotifiers.test_static_notifiers_4c                 C   s&   t dd�}d|_|  |jddg¡ dS )zL Test the name-mangling for the double-underscored change handlers.
        ç       @)r)   ç      @)r)   g        r>   )r)   r>   r?   N)r'   r)   r6   r   r8   r	   r	   r
   Útest_leading_underscore—   s    
z%TestNotifiers.test_leading_underscoreN)r   r   r   Ú__doc__r-   r.   r,   r9   r:   r;   r<   r=   r@   r	   r	   r	   r
   r*   a   s   
r*   )rA   ZunittestZtraitsr   Z
traits.apir   r   r   r   r   r   r   r!   r$   r'   ZTestCaser*   r	   r	   r	   r
   Ú<module>   s   