U W½g€ã@s<ddlZddlmZddlmZdd„ZGdd„deƒZdS) éN)Úgreenleté)ÚTestCasecGst ¡jj|ŽS)N)rÚ getcurrentÚparentÚswitch)Úargs©r úI/opt/hc_python/lib64/python3.8/site-packages/greenlet/tests/test_throw.pyrsrc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)Ú ThrowTestscCs>dd„}t|ƒ}| ¡}| |d¡| t¡}| |d¡dS)NcSs8z tdƒWntk r*tdƒYdSXtdƒdS©NÚokÚfail)rÚ RuntimeErrorr r r r Úf s  z ThrowTests.test_class..fr ©rrÚ assertEqualÚthrowr©ÚselfrÚgÚresr r r Ú test_class s   zThrowTests.test_classcCsvdd„}t|ƒ}| ¡}| |d¡| tdƒ¡}| |d¡t|ƒ}| ¡}| |d¡| td¡}| |d¡dS)NcSsTz tdƒWn:tk rFt ¡d}t|ƒdkrBtdƒYdSYnXtdƒdS)Nr rÚciaor)rrÚsysÚexc_infoÚstr)Úvalr r r rs    zThrowTests.test_val..fr rrrr r r Útest_vals     zThrowTests.test_valcCshdd„}t|ƒ}| ¡}| |d¡| ¡}| t|tjƒ¡| |j¡| ¡}| t|tjƒ¡dS)NcSstdƒtdƒdSr ©rr r r r r2szThrowTests.test_kill..fr )rrrrÚ assertTrueÚ isinstanceZ GreenletExitÚdeadrr r r Ú test_kill1s  zThrowTests.test_killc s0t ¡‰‡fdd„}‡fdd„}t|ƒ}t||d}| t¡| t¡W5QRX| |j¡| |j¡t|ƒ}t||d}| ¡}| |d¡| t¡}| |d¡| |j¡| |j¡t|ƒ}t||d}| ¡}| |d¡| ¡}| |d¡| t¡}| |d¡| |j¡| |j¡dS) Ncs*zˆ d¡Wntk r$YdSXdS)Núf1 ready to catchÚcaughtz normal exit)rÚ IndexErrorr ©Úmainr r Úf1As z9ThrowTests.test_throw_goes_to_original_parent..f1csˆ d¡dS)Núfrom f2rr r'r r Úf2Hsz9ThrowTests.test_throw_goes_to_original_parent..f2)rr$r%r*) rrÚ assertRaisesr&rr r"rr)rr)r+Úg1Úg2rr r'r Ú"test_throw_goes_to_original_parent>s6                  z-ThrowTests.test_throw_goes_to_original_parentc Cs@| t¡}t ¡ ttƒ|¡W5QRX| t|jƒd¡dS)Nz1throw() third argument must be a traceback object) r,Ú TypeErrorrrrÚ ExceptionrrÚ exception©rÚexcr r r Útest_non_traceback_paramfs ý ÿz#ThrowTests.test_non_traceback_paramc Cs@| t¡}t ¡ tƒtƒ¡W5QRX| t|j ƒd¡dS)Nz0instance exception may not have a separate value) r,r0rrrr1Ú BaseExceptionrrr2r3r r r Útest_instance_of_wrong_typeps þ ÿz&ThrowTests.test_instance_of_wrong_typec Cs:| t¡}t ¡ d¡W5QRX| t|jƒd¡dS)NÚabcz1exceptions must be classes, or instances, not str)r,r0rrrrrr2r3r r r Útest_not_throwablezs ÿ ÿzThrowTests.test_not_throwableN) Ú__name__Ú __module__Ú __qualname__rrr#r/r5r7r9r r r r r s (  r )rrÚrrr r r r r Ús