ó
Ė)Tc           @   sg   d  d l  m Z d  d l m Z m Z m Z m Z m Z d  d l Z	 d   Z
 d e f d     YZ d S(   iĸĸĸĸ(   t   TestCase(   t   StringIOt	   long_typet   bt   binary_typet   PY3Nc         C   s&   t  r" t |  t  r" |  j d  S|  S(   Nt   ascii(   R   t
   isinstanceR   t   decode(   t   s(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   as_text_type   s    t   TestDumpc           B   sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C   s3   t    } t j i  |  |  j | j   d  d  S(   Ns   {}(   R   t   jsont   dumpt   assertEqualt   getvalue(   t   selft   sio(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt	   test_dump   s    	c         C   s   x d  t t g D] } |  j t j t j |   | k  |  j t j t j | g   d | k  |  j t j t j i | d 6  d | k  q Wd  S(   Ni    t   a(   t   Nonet   Truet   Falset
   assertTrueR   t   loadst   dumps(   R   t   c(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   test_constants   s    %,c      
   C   sų  t  d  d f d d t d f t d f d t d	  d
 f g } xz | D]r \ } } |  j t j t j i | | 6  i | | 6 |  j t j t j i | | 6d t  i | | 6 qF W|  j	 t
 t j i d t 6 xi  i d d 6i d t  d  6d d 6g D]í } xä t t g D]Ö } t |  } d | t <t d   | j   D  } |  j t j t j | d t d |  |  |  j t j t j i | d 6d t d |  i | d 6 |  j t j t j | g d t d |  | g  qWqWd  S(   Nt   bytesg      ð?s   1.0i
   t   10t   truet   falset   nullid   t   100t	   sort_keysi   t   othert   derpi   t   herpc         s   s'   |  ] \ } } t  |  | f Vq d  S(   N(   R
   (   t   .0t   keyt   val(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pys	   <genexpr>*   s    t   skipkeyst    (   g      ð?s   1.0(   i
   R   (   NR    (   R   R   R   R   R   R   R   R   R   t   assertRaisest	   TypeErrort   dictt   items(   R   R.   t   kt   expectt   vR"   t   v0t   v1(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   test_stringify_key   s:    		"1
!($c         C   s   |  j  t j i   d  d  S(   Ns   {}(   R   R   R   (   R   (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt
   test_dumps5   s    c         C   s   |  j  t j i t t 6t t 6d t d  |  j  t j i d d 6t d  d 6d t 6t t d  6d	 d
 6d t d  d  S(   NR"   s   {"false": true, "true": false}g      @i   i   g      @i   i   i    t   7s3   {"2": 3.0, "4.0": 5, "6": true, "7": 0, "false": 1}(   R   R   R   R   R   R   (   R   (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   test_encode_truefalse8   s    

c         C   sA   d d d d d g } t  j t  j |   } |  j | d  d  S(   Nt   onei   t   twoi   t   threei   t   fouri   t   fivei   s6   {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}(   R8   i   (   R9   i   (   R:   i   (   R;   i   (   R<   i   (   R   R   t   OrderedDictR   (   R   R.   R	   (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   test_ordered_dictF   s
    c         C   sN   d t  f d     Y} t j d d d g d | d  } |  j | d  d	 S(
   s  
        A test against the regression mentioned at `github issue 29`_.

        The indent parameter should accept any type which pretends to be
        an instance of int or long when it comes to being multiplied by
        strings, even if it is not actually an int or long, for
        backwards compatibility.

        .. _github issue 29:
           http://github.com/simplejson/simplejson/issue/29
        t
   AwesomeIntc           B   s    e  Z d  Z d   Z d   Z RS(   s'   An awesome reimplementation of integersc         _   s<   t  |  d k r8 t | d t  r8 | d |  _ q8 n  d  S(   Ni    (   t   lenR   t   intt   _int(   R   t   argst   kwargs(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   __init__^   s    c         S   s*   t  |  d  r |  j | St d   d  S(   NRB   sO   To do non-awesome things with this object, please construct it from an integer!(   t   hasattrRB   t   NotImplementedError(   R   R#   (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   __mul__i   s    (   t   __name__t
   __module__t   __doc__RE   RH   (    (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyR?   [   s   	i    i   i   t   indenti   s   [
   0,
   1,
   2
]N(   t   objectR   R   R   (   R   R?   R	   (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt#   test_indent_unknown_type_acceptanceN   s    $c         C   s3   d g d } |  j  t j t j |   |  d  S(   Ni    i  (   R   R   R   R   (   R   t   lst(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   test_accumulatorv   s    c         C   s   x t  d d  D] } t d   t  |  D  } t   } t j | | d t |  j | j   t j | d t  |  j t j	 | j    |  q Wd  S(   Ni   i    c         s   s!   |  ] } t  |  | f Vq d  S(   N(   t   str(   R&   t   x(    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pys	   <genexpr>~   s    R"   (
   t   rangeR-   R   R   R   R   R   R   R   R   (   R   t   num_keyst   pR   (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   test_sort_keys{   s    	%(   RI   RJ   R   R   R4   R5   R7   R>   RN   RP   RV   (    (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyR   
   s   							(	(   t   unittestR    t   simplejson.compatR   R   R   R   R   t
   simplejsonR   R
   R   (    (    (    s@   /usr/lib64/python2.7/site-packages/simplejson/tests/test_dump.pyt   <module>   s   (	