ó
'=[c           @   s˘   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d d l m Z m	 Z	 d d l
 m Z d d	 l m Z d d
 l
 m Z d e j e f d     YZ d S(   i˙˙˙˙(   t   decodestringN(   t   TestCase(   t   unicode_typei   (   t   readst   writes(   t   nbjsoni   (   t   nb0(   t
   formattestt   TestJSONc           B   sG   e  Z d Z d  Z e Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   t   ipynbc         C   s/   t  t d t } |  j t j |  t  d S(   s.   Ensure that multiline blobs are still readablet   split_linesN(   R   R   t   Falset   assertEqualR   R   (   t   selft   s(    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyt   test_roundtrip_nosplit   s    c         C   s/   t  t d t } |  j t j |  t  d S(   s.   Ensure that splitting multiline blocks is safeR
   N(   R   R   t   TrueR   R   R   (   R   R   (    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyt   test_roundtrip_split   s    c         C   s  t  t d t } t j |  } x t t j  D] \ } } | j j   d k ry | d d } | d | d d } n  | j j   d k r1 | d d d	 } | d | d d d	 } q1 q1 Wx^ | j	   D]P \ }	 }
 |	 d
 k r|
 | d
 j
 t  k st  qÎ |
 | |	 k sÎ t  qÎ Wx^ | j	   D]P \ }	 }
 |	 d
 k ri|
 | d
 j
 t  k st  q/|
 | |	 k s/t  q/Wd S(   s   Test splitlines in mime-bundlesR
   s   Cell with attachmentst   attachmentst   attachment1t   cellss   json_outputs()t   outputsi    t   datas
   text/plainN(   R   R   R   t   jsont   loadst	   enumerateR   t   sourcet   stript   itemst
   splitlinest   AssertionError(   R   R   t   raw_nbt   it   ref_cellt
   attach_reft   attach_jsont
   output_reft   output_jsont   keyt
   json_value(    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyt   test_splitlines    s"    !""c   	      C   sŮ   t  t  } t j |  } t } x | j D] } d | k rC q+ n  xy | j D]n } d | k re qM n  d | j k rM t } | j d } |  j	 t
 |  t  | j d  } t |  } qM qM Wq+ W| sŐ t d   d S(   s   PNG output data is b64 unicodeR   R   s	   image/pngt   asciis   never found png outputN(   R   R   R   R   R   R   R   R   R   R   t   typeR   t   encodeR    R   (	   R   R   t   nb1t	   found_pngt   cellt   outputt   pngdatat   b64bytest	   raw_bytes(    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyt   test_read_png>   s     c   	      C   sŮ   t  t  } t j |  } t } x | j D] } d | k rC q+ n  xy | j D]n } d | k re qM n  d | j k rM t } | j d } |  j	 t
 |  t  | j d  } t |  } qM qM Wq+ W| sŐ t d   d S(   s   JPEG output data is b64 unicodeR   R   s
   image/jpegR)   s   never found jpeg outputN(   R   R   R   R   R   R   R   R   R   R   R*   R   R+   R    R   (	   R   R   R,   t
   found_jpegR.   R/   t   jpegdataR1   R2   (    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyt   test_read_jpegR   s     N(   t   __name__t
   __module__t   Nonet   nb0_reft   extR   t   modR   R   R(   R3   R6   (    (    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyR      s   				(   t   base64R    R   t   unittestR   t   ipython_genutils.py3compatR   R   R   R   t    t
   nbexamplesR   R   t   NBFormatTestR   (    (    (    s:   lib/python2.7/site-packages/nbformat/v4/tests/test_json.pyt   <module>   s   