3
8ßL]˜  ã               @   sR   d Z ddlZddlZddlZddlmZmZ G dd„ deƒZG dd„ dejƒZ	dS )aÇ   Tests for dynamic notifiers with `dispatch='new'`.

Dynamic notifiers created with the `dispatch='new'` option dispatch event
notifications on a new thread. The class handling the dispatch,
`NewTraitChangeNotifyWrapper`, is a subclass of `TraitChangeNotifyWrapper`.
Most of the functionality of the class is thus already covered by the
`TestDynamicNotifiers` test case, and we only need to test that the
notification really occurs on a separate thread.

é    N)ÚFloatÚ	HasTraitsc               @   s   e Zd ZeZdS )ÚFooN)Ú__name__Ú
__module__Ú__qualname__r   Úfoo© r	   r	   úC/tmp/pip-install-5sebvq2j/traits/traits/tests/test_new_notifiers.pyr      s   r   c               @   s   e Zd ZdZdd„ ZdS )ÚTestNewNotifiersz4 Tests for dynamic notifiers with `dispatch='new'`. c                sˆ   g ‰ ‡ fdd„}t ƒ }|j|ddd� d|_tjdƒ | jtˆ ƒdƒ | jˆ d	 dd … |dd	dfƒ tjƒ j	}| j
|ˆ d	 d	 ƒ d S )
Nc                s&   t jƒ j}|| |||f}ˆ j|ƒ d S )N)Ú	threadingÚcurrent_threadÚidentÚappend)ÚobjÚnameÚoldÚnewZ	thread_idÚevent)Únotificationsr	   r
   Úon_foo_notifications   s    
zSTestNewNotifiers.test_notification_on_separate_thread.<locals>.on_foo_notificationsr   r   )Údispatché   gš™™™™™¹?é   r   )r   Zon_trait_changer   ÚtimeÚsleepZassertEqualÚlenr   r   r   ZassertNotEqual)Úselfr   r   Zthis_thread_idr	   )r   r
   Ú$test_notification_on_separate_thread   s    
 
z5TestNewNotifiers.test_notification_on_separate_threadN)r   r   r   Ú__doc__r   r	   r	   r	   r
   r      s   r   )
r   r   r   ZunittestZ
traits.apir   r   r   ZTestCaser   r	   r	   r	   r
   Ú<module>
   s   