File: //usr/local/lib/python3.7/test/test_json/__pycache__/test_tool.cpython-37.pyc
B
��g6 � @ sf d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm Z d dl
mZ G dd� dej�Z
dS )� N)�Popen�PIPE)�support)�assert_python_okc @ sx e Zd ZdZe�d�Ze�d�Zdd� Zddd�Z d d
� Z
dd� Zd
d� Zdd� Z
dd� Ze�ejdkd�dd� �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"
}
]
c C sf t jddf}t|tttd��}|�| j�� �\}}W d Q R X | �|�� | j �� �� � | �|d� d S )Nz-mz json.tool)�stdin�stdout�stderr� )
�sys�
executabler r �communicate�data�encode�assertEqual�
splitlines�expect)�self�args�proc�out�err� r �4/usr/local/lib/python3.7/test/test_json/test_tool.py�test_stdin_stdoutA s
zTestTool.test_stdin_stdoutNc C sB t j}t|ddd��$}| �tj|� |�|p0| j� W d Q R X |S )N�wzutf-8)�encoding)r �TESTFN�open�
addCleanup�os�remove�writer )r r �infile�fpr r r �_create_infileH s
zTestTool._create_infilec C sP | � � }tdd|�\}}}| �|d� | �|�� | j�� �� � | �|d� d S )Nz-mz json.toolr r
)r% r r r r r )r r# �rcr r r r r �test_infile_stdoutO s
zTestTool.test_infile_stdoutc C s^ d}t �d��� }| �|�}tdd|�\}}}| �|d� | �|�� |�� � | �|d� d S )Nu {"msg": "こんにちは"}zP {
"msg": "\u3053\u3093\u306b\u3061\u306f"
}
z-mz json.toolr r
)�textwrap�dedentr r% r r r )r r r r# r&