a  ze@shddlZddlZddlZddlZddlmZddlmZmZeGdddej Z e dkrde dS)N)support) scriptsdirskip_if_missingc@sTeZdZejedZddZdddZ dd Z d d Z d d Z ddZ ddZdS)TestPathfixFunctionalz pathfix.pycCs|tjtjdS)N) addCleanuprunlinkTESTFNselfr P/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_tools/test_pathfix.pysetUpszTestPathfixFunctional.setUprcCs|rtj|d}|}n tj}|}t|ddd$} | |ddWdn1sZ0Yt} t j tj |j g|d|itj d| id d } |d kr| jd kr|d }|| j|| || j| |dtj| || j| |dtj| t|ddd} | } Wdn1s80Y| d} || dddd g| d }| jd kr||||S)Nz script-A_1.pywutf8)encoding zprint("Hello world") z-nZPYTHONIOENCODINGT)envcapture_outputrrz : updating rzprint("Hello world"))ospathjoinrropenwritesysgetfilesystemencoding subprocessrun executablescriptenviron returncode assertEqualstdoutdecodereplacelinesepstderrreadsplit)r ZshebangZ pathfix_flagsexitcoder%r) directoryfilenameZ pathfix_argfrprocoutputlinesZ new_shebangr r r pathfixs@2    (   zTestPathfixFunctional.pathfixcCsXtjd}|tj|t|dtj|d}||j dddg||dddS) Nz.dz recursedown('z') #! /usr/bin/env python-i/usr/bin/python3)r-r)#! /usr/bin/python3) rrrrmtreermkdirrbasenamer$r3)r ZtmpdirZexpected_stderrr r r test_recursive:s  z$TestPathfixFunctional.test_recursivecCs4||dddgd||dddgddS)Nr4r5r6r7#! /usr/bin/env python -Rr$r3r r r r test_pathfixGsz"TestPathfixFunctional.test_pathfixcCs4||dgdd||dgdddS)Nr<)r5r6-kz#! /usr/bin/python3 -Rr4r7r=r r r r test_pathfix_keeping_flagsSsz0TestPathfixFunctional.test_pathfix_keeping_flagscCs|||dgdd||dgdd||dgdd||dgdd ||d gd d dS) Nr4)r5r6-asz#! /usr/bin/python3 -sz#! /usr/bin/env python -Sz#! /usr/bin/env python -V)r5r6rAvr?z#! /usr/bin/python3 -vV)r5r6rAZRsz#! /usr/bin/python3 -Rsz!#! /usr/bin/env python -W default)r5r6rArBr?z#! /usr/bin/python3 -sW defaultr=r r r r test_pathfix_adding_flag_sFz.TestPathfixFunctional.test_pathfix_adding_flagcCs|jdgdddddS)Nz#! /usr/bin/env python -E)r5r6rAz W defaultr?z%-a option doesn't support whitespaces)r,r))r3r r r r test_pathfix_adding_errorszs z0TestPathfixFunctional.test_pathfix_adding_errorsN)rrrr)__name__ __module__ __qualname__rrrrr!r r3r;r>r@rDrFr r r r r s '   r__main__) rrrZunittesttestrZtest.test_toolsrrZTestCaserrGmainr r r r s u