o
    Ti
                     @   s   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zd dlm	Z	 W n# e
yI   zd dlm	Z	 W n e
yF   d dlZdd Z	Y nw Y nw G dd dejZdS )    )with_statementN)strip_python_stderrc                 C   s   t d d |  S )Nz\[\d+ refs\]\r?\n?$ )resubencodestrip)stderr r
   I/home/ubuntu/.local/lib/python3.10/site-packages/hjson/tests/test_tool.pyr      s   r   c                   @   s<   e Zd ZdZedZdddZdd Zdd	 Z	d
d Z
dS )TestToolz

        [["blorpie"],[ "whoops" ] , [
                                 ],	"d-shtaeou","d-nthiouh",
        "i-vhbjkhnth", {"nifty":87}, {"morefield" :	false,"field"
            :"yes"}  ]
           z    [
      [
        blorpie
      ]
      [
        whoops
      ]
      []
      d-shtaeou
      d-nthiouh
      i-vhbjkhnth
      {
        nifty: 87
      }
      {
        morefield: false
        field: yes
      }
    ]
    Nc                 C   sf   t jddg}|r|| tj|tjtjtjd}||\}}| t|d	  | |j
d |S )Nz-mz
hjson.tool)stdinr	   stdoutr   r   )sys
executableextend
subprocessPopenPIPEcommunicateassertEqualr   r   
returncode)selfargsdataargvprocouterrr
   r
   r   runTool7   s   
zTestTool.runToolc                 C   s$   |  | j| j d| j  d S )N)r   )r   r   r   r   expect)r   r
   r
   r   test_stdin_stdoutD   s   zTestTool.test_stdin_stdoutc                 C   sd   t  $}|| j  |  | | j|jgd| j	  W d    d S 1 s+w   Y  d S )Nr   )
tempfileNamedTemporaryFilewriter   r   flushr   r   namer    )r   infiler
   r
   r   test_infile_stdoutI   s   
"zTestTool.test_infile_stdoutc              
   C   s   t  q}|| j  |  t  }zD| | j|j|jgdd  t	|jd}| |
 | j  W d   n1 sBw   Y  W |  tj|jrYt|j n|  tj|jrlt|j w w W d   dS 1 sxw   Y  dS )zNot currently an option in toolr"   r   rbN)r#   r$   r%   r   r   r&   r   r   r'   openreadr    closeospathexistsunlink)r   r(   outfilefr
   r
   r   x_test_infile_outfileQ   s.   
"zTestTool.x_test_infile_outfile)NN)__name__
__module____qualname__r   textwrapdedentr    r   r!   r)   r4   r
   r
   r
   r   r      s    

r   )
__future__r   r.   r   r8   unittestr   r#   test.supportr   ImportErrortest.test_supportr   TestCaser   r
   r
   r
   r   <module>   s&    