a ze(@szddlZddlZddlmZddlmZddlZeeZGdddZ GdddZ Gdd d ej Z e d krvedS) N) gc_collect)assert_python_okc@seZdZeddZdS) FullLoadercCs d|jS)Nz)format__name__)clsmr D/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_module.py module_repr szFullLoader.module_reprN)r __module__ __qualname__ classmethodr r r r r r src@s eZdZdS) BareLoaderN)rr r r r r r rsrc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=S)> ModuleTestscCsltt}||jdu|tt|z|j}|dt |Wnt yVYn0| |j tj dS)Nz __name__ = %s) ModuleType__new__ assertTrue__dict__ assertRaises SystemErrordirrZfailreprAttributeError assertEqual__doc__)selffoosr r r test_uninitializeds  zModuleTests.test_uninitializedcCs tt}|tdt|ddS)Nz"module has no attribute 'not_here'not_here)rrassertRaisesRegexrgetattrrrr r r "test_uninitialized_missing_getattr!s  z.ModuleTests.test_uninitialized_missing_getattrcCstd}|tdt|ddS)Nrz(module 'foo' has no attribute 'not_here'r )rr!rr"r#r r r test_missing_getattr)s z ModuleTests.test_missing_getattrc Csltd}||jd||jd||jd||jd||jd||jdddddddS)Nrrr __loader__ __package____spec__) rrrrassertIsr'r(r)rr#r r r test_no_docstring1s zModuleTests.test_no_docstringc CsDtdd}||jd||jd||jdddddddS)Nrfoodocr&rrrrrr#r r r test_ascii_docstring=s z ModuleTests.test_ascii_docstringc CsDtdd}||jd||jd||jdddddddS)Nr foodocሴr&r-r#r r r test_unicode_docstringGs z"ModuleTests.test_unicode_docstringc Cs|tdd}d|_|j}|dd||jd||jd||jd||jddddddd||j|udS)Nrr/*r,)rrbarr'r(r))rr2r__init__rrrr)rrdr r r test_reinitQs  zModuleTests.test_reinitcCs&dd}t||jdddS)NcSstd}d|_|S)Nr)rr2)rr r r fasz+ModuleTests.test_dont_clear_dict..fr2r6)rrr)rr7r r r test_dont_clear_dict_sz ModuleTests.test_dont_clear_dictcCs<g}td}||_d}t||j~t||dgdS)Nrzwclass A: def __init__(self, l): self.l = l def __del__(self): self.l.append(1) a = A(destroyed))r destroyedexecrrr)rr:rrr r r test_clear_dict_in_ref_cyclehs z(ModuleTests.test_clear_dict_in_ref_cyclecCs:td}t|}|||~t||ddS)Nr)rweakrefrefr*r)rrwrr r r test_weakrefws  zModuleTests.test_weakrefcCsddlm}ddlm}||d||jd||jd|td|jWdn1sh0Y||j dt j d=dS) Nr)testz There is testr9z Deprecated, use whatever insteadzThere is whatevertest.good_getattr) test.good_getattr good_getattrrArxyr!rZyoloZwhateversysmodules)rggarAr r r test_module_getattrs   $zModuleTests.test_module_getattrcCsddlm}ddlm}||jd||jd|t|jWdn1sZ0Y|t|jWdn1s0Yt j d=dt j vrt j d=dS)Nr bad_getattr2r9test.bad_getattrtest.bad_getattr2) test.bad_getattr bad_getattrrArMrrFr TypeErrorZnoperHrIrZbgarMr r r test_module_getattr_errorss   $ $ z&ModuleTests.test_module_getattr_errorscCs,ddlm}|t|gdtjd=dS)Nr)abcrC)rDrErrrHrI)rrJr r r test_module_dirs zModuleTests.test_module_dircCsddlm}ddlm}|tt|Wdn1s@0Y|tt|Wdn1sr0Ytjd=dtjvrtjd=dS)NrrLrNrO) rPrQrArMrrRrrHrIrSr r r test_module_dir_errorss   & & z"ModuleTests.test_module_dir_errorscCsddlm}|t|jWdn1s20Y|t|jWdn1sb0Ydtjvr~tjd=dS)Nr) bad_getattr3ztest.bad_getattr3)rArZrrZoneZ delgetattrrHrI)rrZr r r test_module_getattr_trickys  $ $ z&ModuleTests.test_module_getattr_trickycCs td}|`|t|ddS)Nrz )rrrrrrr r r test_module_repr_minimalsz$ModuleTests.test_module_repr_minimalcCstd}|t|ddSNrzrrrr\r r r test_module_repr_with_namesz&ModuleTests.test_module_repr_with_namecCs"td}d|_|t|ddSNr /tmp/foo.pyz!)r__file__rrr\r r r 'test_module_repr_with_name_and_filenamesz3ModuleTests.test_module_repr_with_name_and_filenamecCs&td}|`d|_|t|ddS)Nrrbz)rrrcrrr\r r r #test_module_repr_with_filename_onlysz/ModuleTests.test_module_repr_with_filename_onlycCstd}|t|ddSr^r_r\r r r $test_module_repr_with_loader_as_Nonesz0ModuleTests.test_module_repr_with_loader_as_NonecCs4td}|`t|_tt}|t|d|dSNrz)rrrr'rrrrrZ loader_reprr r r -test_module_repr_with_bare_loader_but_no_namesz9ModuleTests.test_module_repr_with_bare_loader_but_no_namecCs4td}|`t|_tt}|t|d|dSrg)rrrr'rrrrhr r r -test_module_repr_with_full_loader_but_no_namesz9ModuleTests.test_module_repr_with_full_loader_but_no_namecCs0td}t|_tt}|t|d|dS)Nrz)rrr'rrr)rrr r r r !test_module_repr_with_bare_loaders z-ModuleTests.test_module_repr_with_bare_loadercCs"td}t|_|t|ddS)Nr)rrr'rrr\r r r !test_module_repr_with_full_loaders z-ModuleTests.test_module_repr_with_full_loadercCs(td}t|_d|_|t|ddSra)rrr'rcrrr\r r r .test_module_repr_with_bare_loader_and_filenamesz:ModuleTests.test_module_repr_with_bare_loader_and_filenamecCs(td}t|_d|_|t|ddS)Nrrbrl)rrr'rcrrr\r r r .test_module_repr_with_full_loader_and_filenamesz:ModuleTests.test_module_repr_with_full_loader_and_filenamecCs|ttddS)Nz)rrrH)rr r r test_module_repr_builtinsz$ModuleTests.test_module_repr_builtincCsZtt}d}d}||dt||d||||t| d|d||dS)Nzz{!r} does not start with {!r}z{!r} does not end with {!r})runittestrlenr)rrZ starts_withZ ends_withr r r test_module_repr_sources  z#ModuleTests.test_module_repr_sourcecCs:tdd\}}}|||}|t|hddS)Nz-czfrom test import final_a>sshutil.rmtree = rmtrees final_b.x = bsx = bs len = lensx = as final_a.x = a)rZ assertFalse splitlinesrset)rrcouterrlinesr r r $test_module_finalization_at_shutdown s z0ModuleTests.test_module_finalization_at_shutdowncs:GdddGfdddt}|tt|dddS)Nc@seZdZddZdS)z;ModuleTests.test_descriptor_errors_propagate..DescrcSstdS)N) RuntimeError)rotr r r __get__szCModuleTests.test_descriptor_errors_propagate..Descr.__get__N)rr r rr r r r DescrsrcseZdZZdS)z7ModuleTests.test_descriptor_errors_propagate..MN)rr r melonr rr r MsrZmymodr)rrr|r")rrr rr test_descriptor_errors_propagatesz,ModuleTests.test_descriptor_errors_propagateN)!rr r rr$r%r+r.r0r5r8r<r@rKrTrXrYr[r]r`rdrerfrirjrkrmrnrorprtr{rr r r r rs<             r__main__)rqr=Z test.supportrZtest.support.script_helperrrHtyperrrZTestCaserrmainr r r r s