U W½gõã@slddlmZddlmZddlZddlZddlmZddlmZGdd„deƒZe d krhddl Z e   ¡dS) é)Úprint_function)Úabsolute_importNé)Ú_test_extension)ÚTestCasec@sdeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dS)Ú CAPITestsc Cs | dt t dd„¡¡¡dS)Né2cSsdS)Nr©r r r úW/opt/hc_python/lib64/python3.8/site-packages/greenlet/tests/test_extension_interface.pyÚóz'CAPITests.test_switch..)Ú assertEqualrÚ test_switchÚgreenlet©Úselfr r r r sÿzCAPITests.test_switchcCs.dd„}t |¡}| dtj|ddd¡dS)NcSs||S©Nr ©ÚxÚyr r r Úaddersz+CAPITests.test_switch_kwargs..adderééér)rr rÚtest_switch_kwargs)rrÚgr r r rs zCAPITests.test_switch_kwargscCs,dd„}t |¡ ¡}| dt |¡¡dS)NcSsBdd„}t |¡}| ¡t ¡j |¡t ¡j tdƒ¡dS)NcSs(t ¡j ¡t ¡j ¡tdƒ‚dS)Nz#Should never have reached this code)rÚ getcurrentÚparentÚswitchÚAssertionErrorr r r r Úbarsz2CAPITests.test_setparent..foo..barzShould never reach this code)rrrrÚthrowr)r Úchildr r r Úfoos  ÿz%CAPITests.test_setparent..foo)rrr rÚtest_setparent)rr#Z foo_childr r r r$szCAPITests.test_setparentcCs t ¡dSr)rÚtest_getcurrentrr r r r%*szCAPITests.test_getcurrentcCs| dt dd„¡¡dS)NéñÿÿÿcSsdS)Nr&r r r r r r .r z-CAPITests.test_new_greenlet..)r rÚtest_new_greenletrr r r r'-szCAPITests.test_new_greenletcCs| tjtj¡dSr)Ú assertRaisesrÚ GreenletExitrZtest_raise_dead_greenletrr r r Útest_raise_greenlet_dead0sÿz"CAPITests.test_raise_greenlet_deadcCs| tjtj¡dSr)r(rÚerrorrÚtest_raise_greenlet_errorrr r r r,4sÿz#CAPITests.test_raise_greenlet_errorcslg‰‡fdd„}t |¡}| ¡t |¡| tˆƒd¡| tˆdtƒd¡| t ˆdƒdd¡dS)NcsVzt ¡j ¡Wn>tk r8ˆ t ¡d¡Yntjk rPt ‚YnXdS)Nr) rrrrÚ ValueErrorÚappendÚsysÚexc_infor)rr ©Úseenr r r#;s z!CAPITests.test_throw..foorrz"ValueError was not raised in foo()ztake that sucka!zmessage doesn't match) rrrÚ test_throwr ÚlenZ assertTrueÚ isinstancer-Ústr)rr#rr r1r r38s    þ ýzCAPITests.test_throwc CsB| t¡}t t ¡ttƒ|¡W5QRX| t|j ƒd¡dS)Nz1throw() third argument must be a traceback object) r(Ú TypeErrorrÚtest_throw_exactrrÚ Exceptionr r6Ú exception©rÚexcr r r Útest_non_traceback_paramNs ü ÿz"CAPITests.test_non_traceback_paramc CsD| t¡}t t ¡tƒtƒd¡W5QRX| t |j ƒd¡dS)Nz0instance exception may not have a separate value) r(r7rr8rrr9Ú BaseExceptionr r6r:r;r r r Útest_instance_of_wrong_typeYs ü ÿz%CAPITests.test_instance_of_wrong_typec Cs@| t¡}t t ¡ddd¡W5QRX| t|jƒd¡dS)NÚabcz1exceptions must be classes, or instances, not str) r(r7rr8rrr r6r:r;r r r Útest_not_throwablees ü ÿzCAPITests.test_not_throwableN)Ú__name__Ú __module__Ú __qualname__rrr$r%r'r*r,r3r=r?rAr r r r r s  rÚ__main__) Ú __future__rrr/rÚrrrrBZunittestÚmainr r r r Ús    e