a  ze@sddlmZddlmZddlZddlZddlZdZdZGdddZ Gd d d Z Gd d d Z Gd dde Z ej e ejd\ZZGddde Zej eejd\ZZedkredS))util) machineryNZfinez fine.bogusc@s2eZdZedddZeddZeddZdS) BadSpecFinderLoaderNcCs|tkrt||}|SdSN) SUBMOD_NAMEr ModuleSpec)clsfullnamepathtargetspecrX/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_importlib/import_/test_api.py find_spec s zBadSpecFinderLoader.find_speccCsdSrr)r rrr create_modulesz!BadSpecFinderLoader.create_modulecCs|jtkrtddSNzI cannot be loaded!)__name__r ImportError)modulerrr exec_modules zBadSpecFinderLoader.exec_module)NN)r __module__ __qualname__ classmethodr staticmethodrrrrrrr s   rc@s$eZdZeddZeddZdS)BadLoaderFindercCs|tkr |SdSr)r)r r r rrr find_moduleszBadLoaderFinder.find_modulecCs|tkrtddSr)rr)r r rrr load_module#szBadLoaderFinder.load_moduleN)rrrrrrrrrrrs rc@s<eZdZddZddZddZddZd d Zd d Zd S)APITestcCs8|ttdWdn1s*0YdS)Nzsome module that does not exist) assertRaisesModuleNotFoundErrorrZimport_importlibselfrrrtest_raises_ModuleNotFoundError.s z'APITest.test_raises_ModuleNotFoundErrorcCs8|t|dWdn1s*0YdS)N*)r TypeError __import__r!rrrtest_name_requires_rparition2s z$APITest.test_name_requires_rparitioncCs@|t"|jdtddWdn1s20YdS)Nos)level)r ValueErrorr&globalsr!rrrtest_negative_level7s zAPITest.test_negative_levelc Cstt}dg|_tj|jgdTtt*|tj t<|j tdgdWdn1s^0YWdn1s|0YdS)NXXX meta_pathznot herefromlist) types ModuleTypePKG_NAME__path__r import_statebad_finder_loaderuncachesysmodulesr&r"modrrrtest_nonexistent_fromlist_entry>s    z'APITest.test_nonexistent_fromlist_entryc Cstt}dg|_tj|jgdtt^|tj t<| t *|j tt ddgdWdn1st0YWdn1s0YWdn1s0YdS)Nr.r/.r)r1)r3r4r5r6rr7r8r9r:r;rrr&r rpartitionr<rrr#test_fromlist_load_error_propagatesHs    z+APITest.test_fromlist_load_error_propagatesc Cstt}g|_tj|jgdtttx|t j t<dt j t<| t *}|j ttddgdWdn1s~0Y||jjtWdn1s0YWdn1s0YdS)Nr/r?r)r1)r3r4r5r6rr7r8r9rr:r;rr r&r@Z assertEqual exceptionname)r"r=cmrrrtest_blocked_fromlistUs    $zAPITest.test_blocked_fromlistN) rrrr#r'r-r>rArErrrrr)s   rc@seZdZeZdS) OldAPITestsN)rrrrr8rrrrrFdsrF)r&c@seZdZeZdS) SpecAPITestsN)rrrrr8rrrrrGmsrG__main__)r importlibrr:r3Zunittestr5rrrrrFZ test_bothr&ZFrozen_OldAPITestsZSource_OldAPITestsrGZFrozen_SpecAPITestsZSource_SpecAPITestsrmainrrrrs&   ;