ó
P'^c           @  sã   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z y d  d l m	 Z	 WnN e
 k
 rž y d  d l m	 Z	 Wq― e
 k
 rļ d  d l Z d   Z	 q― Xn Xd   Z d e j f d     YZ d S(   iĸĸĸĸ(   t   with_statementN(   t   strip_python_stderrc         C  s%   t  j d j   d j   |   j   S(   Ns   \[\d+ refs\]\r?\n?$t    (   t   ret   subt   encodet   strip(   t   stderr(    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyR      s    		c          C  s[   t  j d k r- t j d t  }  |  j } n$ t j   \ } } t j | d  }  |  | f S(   Ni   i   t   deletes   w+b(   i   i   (	   t   syst   version_infot   tempfilet   NamedTemporaryFilet   Falset   namet   mkstempt   ost   fdopen(   t   filet   filenamet   fd(    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyt   open_temp_file   s    t   TestToolc           B  sG   e  Z d  Z e j d  Z d d d  Z d   Z d   Z	 d   Z
 RS(   sĘ   

        [["blorpie"],[ "whoops" ] , [
                                 ],	"d-shtaeou","d-nthiouh",
        "i-vhbjkhnth", {"nifty":87}, {"morefield" :	false,"field"
            :"yes"}  ]
           s.      [
        [
            "blorpie"
        ],
        [
            "whoops"
        ],
        [],
        "d-shtaeou",
        "d-nthiouh",
        "i-vhbjkhnth",
        {
            "nifty": 87
        },
        {
            "field": "yes",
            "morefield": false
        }
    ]
    c         C  sĐ   t  j d d g } | r( | j |  n  t j | d t j d t j d t j } | j |  \ } } |  j t |  d j	    |  j | j
 d  | j d  j   S(	   Ns   -ms   simplejson.toolt   stdinR   t   stdoutR   i    t   utf8(   R	   t
   executablet   extendt
   subprocesst   Popent   PIPEt   communicatet   assertEqualR   R   t
   returncodet   decodet
   splitlines(   t   selft   argst   datat   argvt   proct   outt   err(    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyt   runTool@   s    		c         C  s2   |  j  |  j d |  j j    |  j j    d  S(   NR&   (   R    R+   R&   R   t   expectR#   (   R$   (    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyt   test_stdin_stdoutM   s    c         C  sp   t    \ } } zL | j |  j j    | j   |  j |  j d | g  |  j j    Wd  t	 j
 |  Xd  S(   NR%   (   R   t   writeR&   R   t   closeR    R+   R,   R#   R   t   unlink(   R$   t   infilet   infile_name(    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyt   test_infile_stdoutR   s    
c         C  sÞ   t    \ } } zš | j |  j j    | j   t    \ } } zv | j   |  j |  j d | | g  g   t | d  5 } |  j | j   j	 d  j
   |  j j
    Wd  QXWd  t j |  XWd  t j |  Xd  S(   NR%   t   rbR   (   R   R.   R&   R   R/   R    R+   t   opent   readR"   R#   R,   R   R0   (   R$   R1   R2   t   outfilet   outfile_namet   f(    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyt   test_infile_outfile]   s     

N(   t   __name__t
   __module__R&   t   textwrapt   dedentR,   t   NoneR+   R-   R3   R:   (    (    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyR   !   s   			(   t
   __future__R    R   R	   R=   t   unittestR   R   t   test.supportR   t   ImportErrort   test.test_supportR   R   t   TestCaseR   (    (    (    s<   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/tests/test_tool.pyt   <module>   s    		