Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/test_json/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_json/__pycache__/test_tool.cpython-39.opt-2.pyc

a

XC?h �@s^ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	Gdd�dej
�ZdS)�N)�support)�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��inputZcapture_output�textZcheck�)	�sys�
executable�
subprocess�run�data�assertEqual�stdout�expect�stderr��self�args�process�r�=/opt/alt/python39/lib64/python3.9/test/test_json/test_tool.py�test_stdin_stdoutWszTestTool.test_stdin_stdoutNcCsVtj}t|ddd��.}|�tj|�|�|p0|j�Wd�n1sH0Y|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_stdoutds
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,r-r.rrr�test_non_ascii_infileks
zTestTool.test_non_ascii_infilecCs�|��}tjd}tdd||�\}}}|�tj|�t|d��"}|�|�	�|j
�Wd�n1sf0Y|�|d�|�|d�|�|d�dS)N�.outrr�rrr()r'rrrr!r"r#r r�readr)rr%�outfiler,r-r.r&rrr�test_infile_outfilezs
0zTestTool.test_infile_outfilecCs�|��}tdd||�\}}}t|ddd��"}|�|��|j�Wd�n1sR0Y|�|d�|�|d�|�|d�dS)Nrrr4rrrr()r'rr rr5r)rr%r,r-r.r&rrr�test_writing_in_place�s0zTestTool.test_writing_in_placecCsFtjdddf}tj||jdddd�}|�|j|j�|�|jd�dS)Nrrz--json-linesTrr
)	rrr
r�
jsonlines_rawrr�jsonlines_expectrrrrr�test_jsonlines�szTestTool.test_jsonlinescCs>tddd�\}}}|�|d�|�|�d��|�|d�dS)Nrrz-hrsusage: r()rrZ
assertTrue�
startswith)rr,r-r.rrr�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
)	r0r1rrr
rrrr�rZinput_rrrrrr�test_indent�s
zTestTool.test_indentcCsJd}d}tjdddf}tj||dddd�}|�|j|�|�|jd�dS)	Nz[1,
2]z[1, 2]
rrz--no-indentTrr
�rrr
rrrrrBrrr�test_no_indent�szTestTool.test_no_indentcCsJd}d}tjdddf}tj||dddd�}|�|j|�|�|jd�dS)	Nr@z[
	1,
	2
]
rrz--tabTrr
rDrBrrr�test_tab�szTestTool.test_tabcCsJd}d}tjdddf}tj||dddd�}|�|j|�|�|jd�dS)	Nz	[ 1 ,
 2]z[1,2]
rrz	--compactTrr
rDrBrrr�test_compact�szTestTool.test_compactcCs�|�d�}tjd}|�tj|�tddd||�t|d��}|���	�}Wd�n1s^0Ygd�}|�
||�dS)N�{"key":"💩"}r3rrz--no-ensure-ascii�rb)�{s    "key": "💩"�}�r'rrr!r"r#rr r5r)r�rr%r6�f�linesZexpectedrrr�test_no_ensure_ascii_flag�s

*z"TestTool.test_no_ensure_ascii_flagcCs~|�d�}tjd}|�tj|�tdd||�t|d��}|���	�}Wd�n1s\0Ygd�}|�
||�dS)NrHr3rrrI)rJs    "key": "\ud83d\udca9"rKrLrMrrr�test_ensure_ascii_default�s

*z"TestTool.test_ensure_ascii_defaultZwin32z-The test is failed with ValueError on WindowscCsHtjddg}tj|tjtjd�}|j��|�d�|�|j	t
j�dS)Nrr)r�stdins"{}")rrr
�Popen�PIPEr�closeZcommunicater�
returncode�errnoZEPIPE)r�cmd�procrrr�test_broken_pipe_error�s�

zTestTool.test_broken_pipe_error)N)�__name__�
__module__�__qualname__rr0r1r>rr9r:rr'r/r2r7r8r;r=r?rCrErFrGrPrQ�unittestZskipIfr�platformrZrrrrrs,




	
r)rWr"rr0r^r
�testrZtest.support.script_helperrZTestCaserrrrr�<module>s