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_reusecCsLd}|t}||Wdn1s.0Y||jj|dS)NZ dssdsdfff) assertRaises ImportErrorrr exceptionr)rrcmrrrtest_unloadable0s (zLoaderTests.test_unloadablecCsd}t|$t|}|tj|<Wdn1s80Y|t}||Wdn1sl0Y| |j j |dS)NZbuiltin_reload_test) rr rrrrr%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"r1r2rrrtest_get_sourceSsz"InspectLoaderTests.test_get_sourcecCs |jjtjj}||dSr)r r is_packagerr!r"Z assertFalser2rrrtest_is_packageXsz"InspectLoaderTests.test_is_packageNzall modules are built incCsRdD]}t|jj|}q|t}|tjjWdn1sD0YdS)N)r0r5r7)rr r r%r&rr!bad_name)rZ meth_namemethodr(rrrtest_not_builtin]s z#InspectLoaderTests.test_not_builtin) rr,r-r.r4r6r8unittestskipIfrr!r9r;rrrrr/Is r/__main__)rrrZimport_importlibr rrr<r=r!r"rZ test_bothZFrozen_LoaderTestsZSource_LoaderTestsr/ZFrozen_InspectLoaderTestsZSource_InspectLoaderTestsrmainrrrrs"   ;