
    Ne                         d 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l	m
Z
 dd	lmZ dd
lmZ ddlmZ dZej                   j"                  Z G d de      Zy)zTests for the KernelClient    N)TestCase)capture_output   )start_new_kernel   )test_env)KernelSpecManager)NATIVE_KERNEL_NAME)NoSuchKernel   c                   Z     e Zd Zd Z fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z xZS )TestKernelClientc                 \   t               | _        | j                  j                          | j                  | j                  j                         	 t               j                  t               t        t              \  | _        | _        y # t        $ r t        j                          Y =w xY w)N)kernel_name)r   	env_patchstart
addCleanupstopr	   get_kernel_specr
   r   pytestskipr   kmkc)selfs    B/usr/lib/python3/dist-packages/jupyter_client/tests/test_client.pysetUpzTestKernelClient.setUp   sx    !++,	//0BC ,8JK  	KKM	s   B B+*B+c                     | j                   j                          | j                  j                          | j                  j                          t        |          S N)r   r   r   shutdown_kernelr   stop_channelssupertearDown)r   	__class__s    r   r"   zTestKernelClient.tearDown    sA    !w!!    c                     | j                   }t               5 }|j                  dt              }d d d        dj                  v sJ d   d   dk(  sJ y # 1 sw Y   'xY w)Nzprint('hello'))timeouthellocontentstatusok)r   r   execute_interactiveTIMEOUTstdout)r   r   ioreplys       r   test_execute_interactivez)TestKernelClient.test_execute_interactive&   sl    WW 	N**+;W*ME	N"))###Y)T111	N 	Ns   AAc                     | j                  |t               | j                  |d   d   |dz          | j                  |d   d   |dz          y )Nheadermsg_type_replyparent_header_request)assertIsInstancedictassertEqual)r   
reply_typer/   s      r   _check_replyzTestKernelClient._check_reply.   sO    eT*x4j86KL/
;Z*=TUr$   c                     | j                   }|j                  d      }| j                  |t               |j                  ddt              }| j                  d|       y )Nr   )sessionT)r=   r/   r&   history)r   r>   r7   strr,   r;   r   r   msg_idr/   s       r   test_historyzTestKernelClient.test_history3   sO    WWA&fc*

1D'
B)U+r$   c                     | j                   }|j                  d      }| j                  |t               |j                  ddt              }| j                  d|       y )N	who carescodeTr/   r&   inspect)r   rG   r7   r?   r,   r;   r@   s       r   test_inspectzTestKernelClient.test_inspect:   sM    WWK(fc*

6w
?)U+r$   c                     | j                   }|j                  d      }| j                  |t               |j                  ddt              }| j                  d|       y )NrD   rE   TrF   complete)r   rJ   r7   r?   r,   r;   r@   s       r   test_completezTestKernelClient.test_completeA   sM    WW[)fc*F$@*e,r$   c                     | j                   }|j                         }| j                  |t               |j                  dt              }| j                  d|       y )NTrF   kernel_info)r   rM   r7   r?   r,   r;   r@   s       r   test_kernel_infoz!TestKernelClient.test_kernel_infoH   sI    WW!fc*T7;-/r$   c                     | j                   }|j                         }| j                  |t               |j                  dt              }| j                  d|       y )NTrF   	comm_info)r   rP   r7   r?   r,   r;   r@   s       r   test_comm_infozTestKernelClient.test_comm_infoO   sH    WWfc*49+u-r$   c                 n    | j                   }|j                  dt              }| j                  d|       y )NTrF   shutdown)r   rS   r,   r;   )r   r   r/   s      r   test_shutdownzTestKernelClient.test_shutdownV   s-    WW$8*e,r$   c                 h    | j                   }|j                         }| j                  |t               y r   )r   rS   r7   r?   )r   r   rA   s      r   test_shutdown_idz!TestKernelClient.test_shutdown_id[   s&    WWfc*r$   )__name__
__module____qualname__r   r"   r0   r;   rB   rH   rK   rN   rQ   rT   rV   __classcell__)r#   s   @r   r   r      s<    L"2V
,,-0.-
+r$   r   )__doc__osunittestr   r   IPython.utils.capturer   managerr   utilsr   jupyter_client.kernelspecr	   r
   r   r,   pathjoinpjoinr    r$   r   <module>rf      sE      
   0 &  7 8 2

I+x I+r$   