a  ze @spdZddlmZddlZddlZddlZddlZddlmZddl m Z m Z ddl Z e Gddde j ZdS)zTest Tools/scripts/fixcid.py.)StringION)support)skip_if_missing scriptsdirc@s6eZdZddZddZddZddd d d d Zd S)Testc Cs<d}d}|||}d}d}||dj||||ddS)Nzint xx = "xx\"xx"[xx]; zint xx = 'x\'xx' + xx; zint yy = "xx\"xx"[yy]; zint yy = 'x\'xx' + yy; z01 < {old1}> {new1}{new1}2 < {old2}> {new2}{new2})old1old2new1new2) run_scriptassertMultiLineEqualformat)selfrroutputr r rO/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_tools/test_fixcid.pytest_parse_stringsszTest.test_parse_stringscCs |jdddd}||ddS)Nz xx yy *aa bb )z-c-z4/* xx altered */ int xx; /* aa unaltered */ int aa; ) substfileargsinputz1 < /* xx altered */ > /* yy altered */ /* yy altered */ 2 < int xx; > int yy; int yy; /* aa unaltered */ 4 < int aa; > int bb; int bb; )r r )rrrrrtest_alter_commentss zTest.test_alter_commentscCsttj|tjtjtjtjd}t|d}| dWdn1sV0Yttjtjdd}| dWdn1s0Ytjt d}|j tjfd}| |d |dS) Nzfile.cwzint xx; zfile.pyzxx = 'unaltered' fixcid.py)rz{}: 1 < int xx; > int yy; )osmkdirrTESTFN addCleanuprmtreepathjoinopenwriterr r r )rZ c_filenamefilescriptrrrrtest_directory;s  ((zTest.test_directory)rzxx yy )rrc Csptjd}t|d}||Wdn1s40Y|tj|dd|gt|}tj t d}t t d|t t dt |t~}tVztj|ddWn2ty} z|| jd WYd} ~ n d} ~ 00Wdn1s0YWdn1s0YWdn1s>0YWdn1s^0Y|S) Nz.substrrz-sargvstdin__main__)Zrun_namer)rrr!r"runlinklistrrr rZ swap_attrsysrZcaptured_stdoutZcaptured_stderrrunpyZrun_path SystemExitZ assertEqualcodegetvalue) rrrrZ substfilenamer#r'r$rexitrrrr Ls&  (zTest.run_scriptN)r&)__name__ __module__ __qualname__rrr%r rrrrr sr)__doc__iorrZos.pathr-r,testrZtest.test_toolsrrZunittestZTestCaserrrrrs