a  ze@sddlmZddlmZedZddlZddlZddlZeej j dudGdddej Z ej e ed \Z Zeej j dudGd d d Zej eed \ZZed kredS) )abc)utilzimportlib.machineryNzno reasonable builtin modulec@sTeZdZdZddZddZddZdd Zd ZZ d Z d d Z d dZ ddZ d S) LoaderTestsz(Test load_module() for built-in modules.cCsdd|jjd|_dS)Nerrno)__name__ __package__ __loader__) machineryBuiltinImporter verification)selfr[/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_importlib/builtin/test_loader.pysetUpszLoaderTests.setUpcCsH||tj|jD]\}}|t|||q||jt j dS)z;Verify that the module matches against what it should have.N) ZassertIsInstancetypes ModuleTyper items assertEqualgetattrZassertInrsysmodules)rmoduleattrvaluerrrverifyszLoaderTests.verifycCs|jj|SN)r r load_module)rnamerrrrszLoaderTests.load_modulecCsJttjj(|tjj}||Wdn1s<0YdSr)runcacheBUILTINS good_namerr)rrrrr test_moduleszLoaderTests.test_moduleNcCsZttjj8|tjj}|tjj}|||Wdn1sL0YdSr)rr r!r"rZassertIs)rZmodule1Zmodule2rrrtest_module_reuse)szLoaderTests.test_module_reusecCsZd}|tjvsJ|t}||Wdn1s<0Y||jj|dS)NZ dssdsdfff)rbuiltin_module_names assertRaises ImportErrorrr exceptionr)rrcmrrrtest_unloadable0s  (zLoaderTests.test_unloadablecCsd}|tjvsJt|$t|}|tj|<Wdn1sF0Y|t}| |Wdn1sz0Y| |j j |dS)NZbuiltin_reload_test) rr%rr rrrr&r'rrr(r)r module_namerr)rrrtest_already_imported7s  ( (z!LoaderTests.test_already_imported)r __module__ __qualname____doc__rrrr#Z test_packageZtest_lacking_parentZtest_state_after_failurer$r*r,rrrrr sr)r c@sDeZdZdZddZddZddZee j j dud d d Z dS) InspectLoaderTestsz4Tests for InspectLoader methods for BuiltinImporter.cCs |jjtjj}||dSr)r r get_coderr!r" assertIsNonerresultrrr test_get_codeNsz InspectLoaderTests.test_get_codecCs |jjtjj}||dSr)r r get_sourcerr!r"r2r3rrrtest_get_sourceSsz"InspectLoaderTests.test_get_sourcecCs |jjtjj}||dSr)r r is_packagerr!r"Z assertFalser3rrrtest_is_packageXsz"InspectLoaderTests.test_is_packageNzall modules are built incCsRdD]}t|jj|}q|t}|tjjWdn1sD0YdS)N)r1r6r8)rr r r&r'rr!bad_name)rZ meth_namemethodr)rrrtest_not_builtin]s z#InspectLoaderTests.test_not_builtin) rr-r.r/r5r7r9unittestskipIfrr!r:r<rrrrr0Is r0__main__)rrrZimport_importlibr rrr=r>r!r"rZ test_bothZFrozen_LoaderTestsZSource_LoaderTestsr0ZFrozen_InspectLoaderTestsZSource_InspectLoaderTestsrmainrrrrs"   ;