a
    xd                     @   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zd dlm	Z	 W nF e
y   zd dlm	Z	 W n" e
y   d dlZdd Z	Y n0 Y n0 dd ZG dd	 d	ejZdS )
    )with_statementN)strip_python_stderrc                 C   s   t d d |  S )Nz\[\d+ refs\]\r?\n?$ )resubencodestrip)stderr r
   R/var/www/html/Ranjet/env/lib/python3.9/site-packages/simplejson/tests/test_tool.pyr      s
    r   c                  C   s>   t jdkrtjdd} | j}nt \}}t|d} | |fS )N)      F)deletezw+b)sysversion_infotempfileNamedTemporaryFilenamemkstemposfdopen)filefilenamefdr
   r
   r   open_temp_file   s    
r   c                   @   s<   e Zd ZdZedZdddZdd Zdd	 Z	d
d Z
dS )TestToolz

        [["blorpie"],[ "whoops" ] , [
                                 ],	"d-shtaeou","d-nthiouh",
        "i-vhbjkhnth", {"nifty":87}, {"morefield" :	false,"field"
            :"yes"}  ]
           a.      [
        [
            "blorpie"
        ],
        [
            "whoops"
        ],
        [],
        "d-shtaeou",
        "d-nthiouh",
        "i-vhbjkhnth",
        {
            "nifty": 87
        },
        {
            "field": "yes",
            "morefield": false
        }
    ]
    Nc                 C   sp   t jddg}|r|| tj|tjtjtjd}||\}}| t|d	  | |j
d |d S )Nz-mzsimplejson.tool)stdinr	   stdoutr   r   utf8)r   
executableextend
subprocessPopenPIPEcommunicateassertEqualr   r   
returncodedecode
splitlines)selfargsdataargvprocouterrr
   r
   r   runTool@   s    
zTestTool.runToolc                 C   s$   |  | j| j d| j  d S )N)r+   )r%   r0   r+   r   expectr(   )r)   r
   r
   r   test_stdin_stdoutM   s    zTestTool.test_stdin_stdoutc              	   C   s^   t  \}}zB|| j  |  | | j|gd| j  W t	
| nt	
| 0 d S )Nr*   )r   writer+   r   closer%   r0   r1   r(   r   unlink)r)   infileinfile_namer
   r
   r   test_infile_stdoutR   s    
zTestTool.test_infile_stdoutc              	   C   s   t  \}}z|| j  |  t  \}}zx|  | | j||gdg  t|d0}| | 	d
 | j
  W d    n1 s0    Y  W t| nt| 0 W t| nt| 0 d S )Nr3   rbr   )r   r4   r+   r   r5   r%   r0   openreadr'   r(   r1   r   r6   )r)   r7   r8   outfileZoutfile_namefr
   r
   r   test_infile_outfile]   s$    

$zTestTool.test_infile_outfile)NN)__name__
__module____qualname__r+   textwrapdedentr1   r0   r2   r9   r?   r
   r
   r
   r   r   !   s   

r   )
__future__r   r   r   rC   Zunittestr!   r   Ztest.supportr   ImportErrorZtest.test_supportr   r   ZTestCaser   r
   r
   r
   r   <module>   s    	