
    8tf                         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	 d dlm	Z	 d Z G d dej                        Zy# e
$ r 	 d dlm	Z	 n# e
$ r
 d dlZd Z	Y nw xY wY :w xY w)    )with_statementN)strip_python_stderrc                     t        j                  dj                         dj                         |       j                         S )Nz\[\d+ refs\]\r?\n?$ )resubencodestrip)stderrs    d/var/www/html/software/conda/envs/higlass/lib/python3.12/site-packages/simplejson/tests/test_tool.pyr   r      s4    66&--/		      c                      t         j                  dk\  r&t        j                  d      } | j                  }| |fS t        j
                         \  }}t        j                  |d      } | |fS )N)      F)deletezw+b)sysversion_infotempfileNamedTemporaryFilenamemkstemposfdopen)filefilenamefds      r   open_temp_filer      sc    
6!**%899 >  '')HyyU#>r   c                   N    e Zd ZdZ ej
                  d      ZddZd Zd Z	d Z
y)	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                    t         j                  ddg}|r|j                  |       t        j                  |t        j
                  t        j
                  t        j
                        }|j                  |      \  }}| j                  t        |      dj                                | j                  |j                  d       |j                  d      j                         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errs          r   runToolzTestTool.runTool@   s    &78KK&0oo'1'18 ##D)S,S1299;?!,zz&!,,..r   c                     | j                  | j                  | j                  j                               | j                  j                                y )N)r0   )r*   r5   r0   r	   expectr-   )r.   s    r   test_stdin_stdoutzTestTool.test_stdin_stdoutM   s;    LLdii..0L1KK""$	&r   c                 f   t               \  }}	 |j                  | j                  j                                |j	                          | j                  | j                  |g      | j                  j                                t        j                  |       y # t        j                  |       w xY w)Nr/   )r   writer0   r	   closer*   r5   r7   r-   r   unlink)r.   infileinfile_names      r   test_infile_stdoutzTestTool.test_infile_stdoutR   s    ,.	#LL))+,LLN;-0&&(* IIk"BIIk"s   A4B B0c                    t               \  }}	 |j                  | j                  j                                |j	                          t               \  }}	 |j	                          | j                  | j                  ||g      g        t        |d      5 }| j                  |j                         j                  d      j                         | j                  j                                d d d        t        j                  |       	 t        j                  |       y # 1 sw Y   5xY w# t        j                  |       w xY w# t        j                  |       w xY w)Nr:   rbr#   )r   r;   r0   r	   r<   r*   r5   openreadr,   r-   r7   r   r=   )r.   r>   r?   outfileoutfile_namefs         r   test_infile_outfilezTestTool.test_infile_outfile]   s	   ,.	#LL))+,LLN %3$4!G\(  LL{L&ALB ,- $$/::<..0 		,'IIk"  		,'IIk"s>   AE A D, AD ,D, 4E  D)%D, ,EE E)NN)__name__
__module____qualname__r0   textwrapdedentr7   r5   r8   r@   rH    r   r   r   r   !   s4    D X__  	F,/&
	##r   r   )
__future__r   r   r   rL   unittestr&   r   test.supportr   ImportErrortest.test_supportr   r   TestCaser   rN   r   r   <module>rU      sk    % 	 
     0Q#x   Q#-   	 9  	  	 s3   ? A!AA!AA!AA! A!