HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_json/__pycache__/test_tool.cpython-310.opt-1.pyc
o

�i]�@sjddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZGdd�dej�Z
dS)�N)�support)�	os_helper)�assert_python_okc@s�eZdZdZe�d�Ze�d�Ze�d�Ze�d�Z	dd�Z
d)d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Ze�ejd%kd&�d'd(��ZdS)*�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
        }
    ]
    a.    [
        [
            "blorpie"
        ],
        [
            "whoops"
        ],
        [],
        "d-shtaeou",
        "d-nthiouh",
        "i-vhbjkhnth",
        {
            "nifty": 87
        },
        {
            "morefield": false,
            "field": "yes"
        }
    ]
    zr    {"ingredients":["frog", "water", "chocolate", "glucose"]}
    {"ingredients":["chocolate","steel bolts"]}
    z�    {
        "ingredients": [
            "frog",
            "water",
            "chocolate",
            "glucose"
        ]
    }
    {
        "ingredients": [
            "chocolate",
            "steel bolts"
        ]
    }
    cCsDtjddf}tj||jdddd�}|�|j|j�|�|jd�dS)N�-m�	json.toolT��input�capture_output�text�check�)	�sys�
executable�
subprocess�run�data�assertEqual�stdout�expect�stderr��self�args�process�r�5/usr/local/lib/python3.10/test/test_json/test_tool.py�test_stdin_stdoutXszTestTool.test_stdin_stdoutNcCsXtj}t|ddd��}|�tj|�|�|p|j�Wd�|S1s%wY|S)N�w�utf-8��encoding)r�TESTFN�open�
addCleanup�os�remove�writer)rr�infile�fprrr�_create_infile^s
��zTestTool._create_infilecCsP|��}tdd|�\}}}|�|d�|�|��|j�����|�|d�dS)Nrrr�)r*rr�
splitlinesr�encode�rr(�rc�out�errrrr�test_infile_stdoutes
zTestTool.test_infile_stdoutcCs^d}t�d���}|�|�}tdd|�\}}}|�|d�|�|��|���|�|d�dS)Nu{"msg": "こんにちは"}zP        {
            "msg": "\u3053\u3093\u306b\u3061\u306f"
        }
        rrrr+)�textwrap�dedentr-r*rrr,)rrrr(r/r0r1rrr�test_non_ascii_infilels�
zTestTool.test_non_ascii_infilecCs�|��}tjd}tdd||�\}}}|�tj|�t|ddd��}|�|�	�|j
�Wd�n1s5wY|�|d�|�|d�|�|d�dS)	N�.outrr�rrr rr+)r*rr"rr$r%r&r#r�readr)rr(�outfiler/r0r1r)rrr�test_infile_outfile{s
�zTestTool.test_infile_outfilecCs�|��}tdd||�\}}}t|ddd��}|�|��|j�Wd�n1s)wY|�|d�|�|d�|�|d�dS)Nrrr7rr rr+)r*rr#rr8r)rr(r/r0r1r)rrr�test_writing_in_place�s�zTestTool.test_writing_in_placecCsFtjdddf}tj||jdddd�}|�|j|j�|�|jd�dS)Nrrz--json-linesTrr
)	rrrr�
jsonlines_rawrr�jsonlines_expectrrrrr�test_jsonlines�szTestTool.test_jsonlinescCs>tddd�\}}}|�|d�|�|�d��|�|d�dS)Nrrz-hrsusage: r+)rrZ
assertTrue�
startswith)rr/r0r1rrr�test_help_flag�szTestTool.test_help_flagcCsR|��}tddd|�\}}}|�|d�|�|��|j�����|�|d�dS)Nrrz--sort-keysrr+)r*rrr,�expect_without_sort_keysr-r.rrr�test_sort_keys_flag�s
�zTestTool.test_sort_keys_flagcCsRd}t�d�}tjddddf}tj||dddd�}|�|j|�|�|jd	�dS)
N�[1, 2]z5        [
          1,
          2
        ]
        rrz--indent�2Trr
)	r3r4rrrrrrr�rZinput_rrrrrr�test_indent�s
zTestTool.test_indentcC�Jd}d}tjdddf}tj||dddd�}|�|j|�|�|jd�dS)	Nz[1,
2]z[1, 2]
rrz--no-indentTrr
�rrrrrrrrErrr�test_no_indent��zTestTool.test_no_indentcCrG)	NrCz[
	1,
	2
]
rrz--tabTrr
rHrErrr�test_tab�rJzTestTool.test_tabcCrG)	Nz	[ 1 ,
 2]z[1,2]
rrz	--compactTrr
rHrErrr�test_compact�rJzTestTool.test_compactcCs�|�d�}tjd}|�tj|�tddd||�t|d��}|���	�}Wd�n1s/wYgd�}|�
||�dS)N�{"key":"💩"}r6rrz--no-ensure-ascii�rb)�{s    "key": "💩"�}�r*rr"r$r%r&rr#r8r,r�rr(r9�f�linesZexpectedrrr�test_no_ensure_ascii_flag�s

�z"TestTool.test_no_ensure_ascii_flagcCs~|�d�}tjd}|�tj|�tdd||�t|d��}|���	�}Wd�n1s.wYgd�}|�
||�dS)NrMr6rrrN)rOs    "key": "\ud83d\udca9"rPrQrRrrr�test_ensure_ascii_default�s

�z"TestTool.test_ensure_ascii_default�win32z-The test is failed with ValueError on WindowscCsHtjddg}tj|tjtjd�}|j��|�d�|�|j	t
j�dS)Nrr)r�stdins"{}")rrr�Popen�PIPEr�close�communicater�
returncode�errno�EPIPE)r�cmd�procrrr�test_broken_pipe_error�s�

zTestTool.test_broken_pipe_error)N)�__name__�
__module__�__qualname__rr3r4rArr<r=rr*r2r5r:r;r>r@rBrFrIrKrLrUrV�unittestZskipIfr�platformrbrrrrr
s.




	
r)r^r%rr3rfr�testrZtest.supportrZtest.support.script_helperrZTestCaserrrrr�<module>s