ó
ßüÚ\c           @` sĢ   d  d l  m Z m Z m Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l
 m Z m Z m Z d  d l m Z m Z m Z d   Z d   Z d	   Z d
 S(   i    (   t   print_functiont   divisiont   absolute_import(   t   Mock(   t   gen(   t   IOLoop(   t   RemoteClientt   _submitt   _remote(   t   valid_python_scriptt   invalid_python_scriptt   loopc         ` s2   t  j    f d    } |  j | d d d  S(   Nc          3` so   t  d d d t     }  |  j   Vt d j |  j  t    V\ } } d | k s` t  |  j   Vd  S(   Nt   ips	   127.0.0.1t	   local_dirs   127.0.0.1:{0}s   hello world!(   R   t   strt   _startR   t   formatt   portt   AssertionErrort   _close(   t   remote_clientt   outt   err(   t   tmpdirR	   (    s@   lib/python2.7/site-packages/distributed/tests/test_submit_cli.pyt   test   s    %t   timeouti   (   R   t	   coroutinet   run_sync(   R   R   R	   R   (    (   R   R	   s@   lib/python2.7/site-packages/distributed/tests/test_submit_cli.pyt,   test_dask_submit_cli_writes_result_to_stdout   s    c         ` s2   t  j    f d    } |  j | d d d  S(   Nc          3` so   t  d d d t    }  |  j   Vt d j |  j  t     V\ } } d | k s` t  |  j   Vd  S(   NR   s	   127.0.0.1R   s   127.0.0.1:{0}t	   Traceback(   R   R   R   R   R   R   R   R   (   R   R   R   (   R
   R   (    s@   lib/python2.7/site-packages/distributed/tests/test_submit_cli.pyR       s    %R   i   (   R   R   R   (   R   R   R
   R   (    (   R
   R   s@   lib/python2.7/site-packages/distributed/tests/test_submit_cli.pyt/   test_dask_submit_cli_writes_traceback_to_stdout   s    c          C` sĶ   t  d t  }  t  d t j    } t d d d | d |  |  j d d d |  |    j j d d	  | j j s{ t  | j	 j s t  |    j
 j sĒ t  d  S(
   Nt   specs   127.0.0.1:8799iT"  R   t   clientR   s	   127.0.0.1R   i_"  (   R   R   R   t   currentR   t   assert_called_once_witht   startt   calledR   t   closet   stop(   t   mock_remote_clientt   mock_ioloop(    (    s@   lib/python2.7/site-packages/distributed/tests/test_submit_cli.pyt   test_cli_runs_remote_client.   s    N(   t
   __future__R    R   R   t   mockR   t   tornadoR   t   tornado.ioloopR   t   distributed.submitR   R   R   t   distributed.utils_testR	   R
   R   R   R   R)   (    (    (    s@   lib/python2.7/site-packages/distributed/tests/test_submit_cli.pyt   <module>   s   		