3
Yd                 @   s   d Z ddlmZ ddlZddljjZddlj	j
Zdd Zdd ZG dd	 d	eZejjd
dddgdd Zejjd
dddgejjdddgdd ZdS )zTests for workflow callbacks
    )sleepNc               C   s   d S )N r   r   r   ]/var/www/html/virt/lib/python3.6/site-packages/nipype/pipeline/plugins/tests/test_callback.pyfunc   s    r   c               C   s   t d S )N)	Exceptionr   r   r   r   bad_func   s    r   c               @   s   e Zd Zdd ZdddZdS )Statusc             C   s
   g | _ d S )N)statuses)selfr   r   r   __init__   s    zStatus.__init__Nc             C   s   | j j|j|f d S )N)r	   appendname)r
   nodestatusresultr   r   r   callback   s    zStatus.callback)N)__name__
__module____qualname__r   r   r   r   r   r   r      s   r   pluginZLinearZ	MultiProcZLegacyMultiProcc             C   s   | j   t }tjd| jd}tjtjtg g ddd}|j	|g |j
dd|jd< |j|d	|jid
 |jddgks|td S )Ntest)r   base_dir)functioninput_namesoutput_namesf_node)r      )crashdump_dirpoll_sleep_duration	executionstatus_callback)r   plugin_argsstartend)r   r"   )r   r#   )chdirr   peWorkflowstrpathNodeniuFunctionr   	add_nodesr   configrunr   r	   AssertionError)tmpdirr   sowfr   r   r   r   test_callback_normal   s    r2   stop_on_first_crashFTc             C   s   | j   t }tjd| jd}tjtjtg g ddd}|j	|g |j
|dd|jd< tjt |j|d	|jid
 W d Q R X td |jddgkstd S )Nr   )r   r   )r   r   r   r   )r   r   )r   r3   r   r   r    )r   r!   g      ?r"   	exception)r   r"   )r   r4   )r$   r   r%   r&   r'   r(   r)   r*   r   r+   r   r,   pytestZraisesr   r-   r   r   r	   r.   )r/   r   r3   r0   r1   r   r   r   r   test_callback_exception+   s    r6   )__doc__timer   r5   Znipype.interfaces.utilityZ
interfacesZutilityr)   Znipype.pipeline.engineZpipelineZenginer%   r   r   objectr   markZparametrizer2   r6   r   r   r   r   <module>   s   