U W½g° ã@sxddlmZddlmZddlZddlZddlZddlmZddlmZddlm Z Gdd „d eƒZ e d krte  ¡dS) é)Úprint_function)Úabsolute_importNé)Ú_test_extension_cpp)ÚTestCase)ÚWINc@sHeZdZdd„Zdd„Zdd„Zdd„Ze e d ¡d d „ƒZ d d „Z dS)ÚCPPTestscCsXg}tdƒD]$}t tj¡}| |¡| |¡q t|ƒD]\}}| | ¡|¡q:dS)Né)ÚrangeÚgreenletrÚtest_exception_switchÚswitchÚappendÚ enumerateZ assertEqual)ÚselfZ greenletsÚiÚg©rúG/opt/hc_python/lib64/python3.8/site-packages/greenlet/tests/test_cpp.pyr s    zCPPTests.test_exception_switchc Cs ddl}ddl}|j |j t¡d¡}|j|t|tƒs<|j n|g}|}|  t j ¡}t j |dt jdW5QRX|j}| ¡} | |j| ¡| d|j¡|jS)Nrzfail_cpp_exception.pyzutf-8)ÚencodingÚstderrzfail_cpp_exception is running)ÚosÚsysÚpathÚjoinÚdirnameÚ__file__Ú executableÚ isinstanceÚstrÚ__name__Z assertRaisesÚ subprocessÚCalledProcessErrorÚ check_outputÚSTDOUTÚ exceptionZ,get_expected_returncodes_for_aborted_processÚassertInÚ returncodeÚoutput) rÚtargetrrÚscriptÚargsZ__traceback_info__ÚexcÚexZ expected_exitrrrÚ_do_test_unhandled_exceptions& þýz%CPPTests._do_test_unhandled_exceptioncCs| tj¡dS©N)r.rZtest_exception_throw_nonstd©rrrrÚ&test_unhandled_nonstd_exception_aborts-sz/CPPTests.test_unhandled_nonstd_exception_abortscCs| tj¡dSr/)r.rZtest_exception_throw_stdr0rrrÚ#test_unhandled_std_exception_aborts1sz,CPPTests.test_unhandled_std_exception_abortsz#XXX: This does not crash on WindowscCs| d¡}| d|¡dS)NZrun_as_greenlet_targetzThrown from an extension.)r.r&)rr(rrrÚ8test_unhandled_std_exception_as_greenlet_function_aborts5s  úzACPPTests.test_unhandled_std_exception_as_greenlet_function_abortscCs| d¡dS)NZ*run_unhandled_exception_in_greenlet_aborts)r.r0rrrÚ+test_unhandled_exception_in_greenlet_abortsCsz4CPPTests.test_unhandled_exception_in_greenlet_abortsN) r Ú __module__Ú __qualname__r r.r1r2ÚunittestZskipIfrr3r4rrrrr s   rÚ__main__) Ú __future__rrr!r7r Úrrrrr ÚmainrrrrÚs     <