a  zeG"@sddlmZddlmZedZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl Z ddlZGdddejZGd d d eZejeed \ZZGd d d eZejeed \ZZGdddeZejeed \ZZedkre dS))abc)utilzimportlib.machineryN)make_legacy_pycc@seZdZddZddZd!dddddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZeejdkdddZdd ZdS)" FinderTestscCs4|jj|jjf|jj|jjfg}|jj|g|RSN) machinerySourceFileLoaderSOURCE_SUFFIXESSourcelessFileLoaderBYTECODE_SUFFIXES FileFinder)selfrootloader_detailsrZ/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_importlib/source/test_finder.py get_finder)szFinderTests.get_findercCs||}|j||ddS)NT loader_only)r_find)rrmodulefinderrrrimport_0s zFinderTests.import_Ncompile_unlinkc Cs|dur|h}tj|}|r6|D]}t||q"|r|D]V}t||zt||Wq>ty}z|jtj kr~WYd}~q>d}~00q>| |d|}| t |d|WdS1s0YdS)N.root load_module) rcreate_modules py_compilecompileosrrOSErrorerrnoENOENTr assertTruehasattr) rtestZcreaterrmappingnameerrorloaderrrrrun_test4s"  zFinderTests.run_testcCs2|d|jddhdhd|jddhddS)NZ top_levelrrr-rrrr test_moduleQs   zFinderTests.test_modulecCs>|ddh|jddhdhdhd|jddhdhddS)NZpkg pkg.__init__rr.r/r0rrr test_package[s zFinderTests.test_packagecCs\tdd<}tj|d}||d}|t|dWdn1sN0YdS)Nr2pkg.subrrrr"pathdirnamerr&r')rr)pkg_dirr,rrrtest_module_in_packagees z"FinderTests.test_module_in_packagecCs`tdd}|<}tj|d}||d}|t|dWdn1sR0YdS)Nr2zpkg.sub.__init__r4rr5)rcontextr)r8r,rrrtest_package_in_packagels   z#FinderTests.test_package_in_packagecCs0d}||d||h}|d||dS)NZ_tempz {0}.__init____init__)r-formatZassertIn get_filename)rr*r,rrrtest_package_over_moduletsz$FinderTests.test_package_over_modulecCsHtd*}||dd}||Wdn1s:0YdS)NZblahrZ sdfsadsadf)rrr assertIsNone)rr)Znothingrrr test_failureys zFinderTests.test_failurec Cs|jd|jj|jjf}tdd}|dWdn1sD0Yz.|j|ddd}|t|dWt dn t d0dS) Nzmod.pywz# test file for importlibmodTrr) rr r r openwriterr&r'r"r)rrfiler,rrrtest_empty_string_for_dir~s (z%FinderTests.test_empty_string_for_dircCs:|jd|jj|jjf}d|_|||jddS)NrB*)rr r r _path_mtimeinvalidate_caches assertEqual)rrrrrtest_invalidate_cachess z"FinderTests.test_invalidate_cachescCstd}t|8}||d}|j|ddd}||Wdn1sL0Y|j|ddd}||dS)NrDrTr)rrrrZassertIsNotNoner@)rrDr)rfoundrrrtest_dir_removal_handlings (z%FinderTests.test_dir_removal_handlingwin32z>os.chmod() does not support the needed arguments under Windowscsnt}t|jjfdd}|||t|jtjtj B| |j}| |d}| ||j dS)Ncs t|j|ddddSr)r"chmodr*__exit__)tempdirZ original_moderrcleanupsz3FinderTests.test_no_read_directory..cleanup doesnotexist)tempfileTemporaryDirectoryr"statr*st_modeZ addCleanuprRS_IWUSRS_IXUSRrrrM NOT_FOUND)rrTrVrrOrrUrtest_no_read_directorys   z"FinderTests.test_no_read_directorycCsRt6}||j}||d}|||jWdn1sD0YdS)NrW)rXNamedTemporaryFilerr*rrMr^)rZfile_objrrOrrrtest_ignore_files   zFinderTests.test_ignore_file)N)__name__ __module__ __qualname__rrr-r1r3r9r;r?rArHrNrPunittestZ skipUnlesssysplatformr_rarrrrrs"      rc@seZdZdZdddZdS)FinderTestsPEP451NFcCs||}|dur|jS|Sr) find_specr,)rrr*rspecrrrrs zFinderTestsPEP451._find)Frbrcrdr^rrrrrrhsrh)rc@seZdZdgfZdddZdS)FinderTestsPEP420NFcCsRt6tdt||}|r,|dn|WdS1sD0YdS)Nignorer)warningscatch_warnings simplefilterDeprecationWarning find_loader)rrr*rZloader_portionsrrrrs   zFinderTestsPEP420._find)Frkrrrrrlsrlc@seZdZdZdddZdS)FinderTestsPEP302NFcCsBt&tdt||WdS1s40YdS)Nrm)rnrorprq find_module)rrr*rrrrrs  zFinderTestsPEP302._find)Frkrrrrrssrs__main__)rBrrZimport_importlibrr$r"r rZrfrXZ test.supportrrernrrhZ test_bothZFrozen_FinderTestsPEP451ZSource_FinderTestsPEP451rlZFrozen_FinderTestsPEP420ZSource_FinderTestsPEP420rsZFrozen_FinderTestsPEP302ZSource_FinderTestsPEP302rbmainrrrrs6    .