o
    KXh                     @   s|   d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZ ddlZe  G dd dejZdS )	zTest Tools/scripts/fixcid.py.    )StringION)support)	os_helper)skip_if_missing
scriptsdirc                   @   s6   e Zd Zdd Zdd Zdd Zddd	d
ddZdS )Testc              	   C   s<   d}d}|  || }d}d}| |dj||||d d S )Nzint xx = "xx\"xx"[xx];
zint xx = 'x\'xx' + xx;
zint yy = "xx\"xx"[yy];
zint yy = 'x\'xx' + yy;
z01
< {old1}> {new1}{new1}2
< {old2}> {new2}{new2})old1old2new1new2)
run_scriptassertMultiLineEqualformat)selfr   r	   outputr
   r    r   E/opt/python-3.10.19/usr/lib/python3.10/test/test_tools/test_fixcid.pytest_parse_strings   s   
zTest.test_parse_stringsc                 C   s    | j dddd}| |d d S )Nzxx yy
*aa bb
)z-c-z4/* xx altered */
int xx;
/* aa unaltered */
int aa;
)	substfileargsinputz1
< /* xx altered */
> /* yy altered */
/* yy altered */
2
< int xx;
> int yy;
int yy;
/* aa unaltered */
4
< int aa;
> int bb;
int bb;
)r   r   )r   r   r   r   r   test_alter_comments    s   zTest.test_alter_commentsc                 C   s   t tj | tjtj t jtjd}t|d}|	d W d    n1 s+w   Y  tt jtjdd}|	d W d    n1 sKw   Y  t jt
d}| jtjfd}| |d| d S )	Nzfile.cwzint xx;
zfile.pyzxx = 'unaltered'
	fixcid.py)r   z{}:
1
< int xx;
> int yy;
)osmkdirr   TESTFN
addCleanuprmtreepathjoinopenwriter   r   r   r   )r   Z
c_filenamefilescriptr   r   r   r   test_directory<   s   zTest.test_directory )r   zxx yy
)r   r   c          
      C   s  t jd }t|d}|| W d    n1 sw   Y  | t j| dd|gt| }tj	t
d}ttd|y ttdt|S t ?}t + z	tj|dd W n tyt }	 z| |	jd	 W Y d }	~	nd }	~	ww W d    n1 sw   Y  W d    n1 sw   Y  W d    n1 sw   Y  W d    | S W d    | S 1 sw   Y  | S )
Nz.substr   r   z-sargvstdin__main__)Zrun_namer   )r   r   r"   r#   r   unlinklistr   r    r!   r   r   Z	swap_attrsysr   Zcaptured_stdoutZcaptured_stderrrunpyZrun_path
SystemExitZassertEqualcodegetvalue)
r   r   r   r   Zsubstfilenamer$   r(   r%   r   exitr   r   r   r   M   s@   
 ( zTest.run_scriptN)r'   )__name__
__module____qualname__r   r   r&   r   r   r   r   r   r      s
    r   )__doc__ior   r   Zos.pathr.   r-   testr   Ztest.supportr   Ztest.test_toolsr   r   ZunittestZTestCaser   r   r   r   r   <module>   s    