
    4j                     r    S SK r S SKrS SKrS SKrS SKrS SKrS SKrS rS r " S S\R                  5      r
g)    Nc                 N    [         R                  " SSU 5      R                  5       $ )z.Strip debug-build refcount output from stderr.s   \[\d+ refs\]\r?\n?$    )resubstrip)stderrs    Y/root/lseg-credit/backend/venv/lib/python3.13/site-packages/simplejson/tests/test_tool.pystrip_python_stderrr
   	   s    66-sF;AACCr   c                  H    [         R                  " SS9n U R                  nX4$ )NF)delete)tempfileNamedTemporaryFilename)filefilenames     r	   open_temp_filer      s#    &&e4DyyH>r   c                   X    \ rS rSrSr\R                  " S5      rS
S jrS r	S r
S rS	rg)TestTool   z

        [["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                    [         R                  S:X  a  U R                  S5        [         R                  SS/nU(       a  UR	                  U5        [
        R                  " U[
        R                  [
        R                  [
        R                  S9nUR                  U5      u  pVU R                  [        U5      SR                  5       5        U R                  UR                  S5        UR                  S5      R                  5       $ )	N
emscriptenz&subprocess not available on Emscriptenz-mzsimplejson.tool)stdinr   stdout r   utf8)sysplatformskipTest
executableextend
subprocessPopenPIPEcommunicateassertEqualr
   encode
returncodedecode
splitlines)selfargsdataargvprocouterrs          r	   runToolTestTool.runTool1   s    <<<'MMBC&78KK&0oo'1'18 ##D),S1299;?!,zz&!,,..r   c                     U R                  U R                  U R                  R                  5       S9U R                  R                  5       5        g )N)r,   )r%   r1   r,   r&   expectr)   )r*   s    r	   test_stdin_stdoutTestTool.test_stdin_stdout@   s;    LLdii..0L1KK""$	&r   c                 b   [        5       u  p UR                  U R                  R                  5       5        UR	                  5         U R                  U R                  U/S9U R                  R                  5       5        [        R                  " U5        g ! [        R                  " U5        f = f)Nr+   )r   writer,   r&   closer%   r1   r4   r)   osunlink)r*   infileinfile_names      r	   test_infile_stdoutTestTool.test_infile_stdoutE   s}    ,.	#LL))+,LLN;-0&&(* IIk"BIIk"s   A1B B.c                    [        5       u  p UR                  U R                  R                  5       5        UR	                  5         [        5       u  p4 UR	                  5         U R                  U R                  X$/S9/ 5        [        US5       nU R                  UR                  5       R                  S5      R                  5       U R                  R                  5       5        S S S 5        [        R                  " U5         [        R                  " U5        g ! , (       d  f       N<= f! [        R                  " U5        f = f! [        R                  " U5        f = f)Nr8   rbr   )r   r9   r,   r&   r:   r%   r1   openreadr(   r)   r4   r;   r<   )r*   r=   r>   outfileoutfile_namefs         r	   test_infile_outfileTestTool.test_infile_outfileP   s    ,.	#LL))+,LLN %3$4!G(  LL{&ALB ,-$$/::<..0 . 		,'IIk" .- 		,'IIk"s=   AE <D- AD&D- .E 
D*&D- -EE E  )NN)__name__
__module____qualname____firstlineno__r,   textwrapdedentr4   r1   r5   r?   rH   __static_attributes__rJ   r   r	   r   r      s2    D __  	F,/&
	##r   r   )r;   r   r   rO   unittestr!   r   r
   r   TestCaser   rJ   r   r	   <module>rT      s9    	 	 
    D
S#x   S#r   