a 7êdg>“ã@sdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z z ddl Z Wne yndZ Yn0ddlZddlZddlZddlZddlZddlZddlmZddlZejdkrÆddlZddlZddlmZddlmZddlmZddlmZdd lmZdd lm Z dd l!m"Z"dd l!m#Z#m$Z$m%Z%d d„Z&dd„Z'dd„Z(Gdd„dƒZ)Gdd„dej*ƒZ+Gdd„de+ƒZ,Gdd„dej-ƒZ.Gdd„dej*ƒZ/Gdd„dej0ƒZ1Gdd „d ej2ƒZ3Gd!d"„d"ƒZ4Gd#d$„d$ƒZ5ejdkrGd%d&„d&e4ej6ƒZ7Gd'd(„d(e4e5ej6ƒZ8n”ddl9Z9Gd)d*„d*e4ƒZ:e;e9d+ƒrTGd,d-„d-e:e5ej6ƒZGd4d&„d&e:e5ej6ƒZ7d5d6„Z?Gd7d8„d8ej6ƒZ@Gd9d:„d:ej6ƒZAGd;d<„d„d>ej6ƒZCGd?d@„d@ƒZDGdAdB„dBeDej6ƒZEz ddlFZFWne y@Yn0GdCdD„dDeDej6ƒZGGdEdF„dFej6ƒZHGdGdH„dHej6ƒZIeJdIkrŒe K¡dS)JzTests for events.py.éN)ÚmockÚwin32)Ú coroutines)Úevents)Úproactor_events)Úselector_events)Úutils)Úsupport)Ú socket_helper)Ú ALWAYS_EQÚLARGESTÚSMALLESTcCst d¡dS©N)ÚasyncioÚset_event_loop_policy©rrú9/usr/local/lib/python3.9/test/test_asyncio/test_events.pyÚtearDownModule'srcCsFtj d¡rdStjdkrdSt ¡d}ttt| d¡ƒƒ}|dkS)z4Return True if the platform is Mac OS 10.4 or older.ZaixTÚdarwinFrÚ.)é é)ÚsysÚplatformÚ startswithZmac_verÚtupleÚmapÚintÚsplit)ÚversionrrrÚbroken_unix_getsockname+s   r cCs&dd„}t ¡}t |¡| |ƒ¡S)NcÓsdS©NÚhellorrrrrÚdoit7sz8_test_get_event_loop_new_process__sub_proc..doit)rÚnew_event_loopÚset_event_loopÚrun_until_complete)r#ÚlooprrrÚ*_test_get_event_loop_new_process__sub_proc6s r(c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚCoroLikecCsdSrr)ÚselfÚvrrrÚsend@sz CoroLike.sendcGsdSrr©r*ÚexcrrrÚthrowCszCoroLike.throwcCsdSrr©r*rrrÚcloseFszCoroLike.closecCsdSrrr0rrrÚ __await__IszCoroLike.__await__N)Ú__name__Ú __module__Ú __qualname__r,r/r1r2rrrrr)?sr)c@s>eZdZdZdZd dd„Zdd„Zdd„Zdd „Zd d „Z dS) Ú MyBaseProtoNcCs2d|_d|_d|_|dur.| ¡|_| ¡|_dS©NÚINITIALr)Ú transportÚstateÚnbytesÚ create_futureÚ connectedÚdone©r*r'rrrÚ__init__Qs  zMyBaseProto.__init__cCs"||_d|_|jr|j d¡dS©NÚ CONNECTED©r9r:r=Ú set_result©r*r9rrrÚconnection_madeYszMyBaseProto.connection_madecCs|jt|ƒ7_dSr©r;Úlen©r*ÚdatarrrÚ data_received`szMyBaseProto.data_receivedcCs d|_dS©NÚEOF)r:r0rrrÚ eof_receiveddszMyBaseProto.eof_receivedcCsd|_|jr|j d¡dS©NÚCLOSED©r:r>rDr-rrrÚconnection_losthszMyBaseProto.connection_lost)N) r3r4r5r=r>r@rFrKrNrRrrrrr6Ms r6cseZdZ‡fdd„Z‡ZS)ÚMyProtocstƒ |¡| d¡dS)Ns%GET / HTTP/1.0 Host: example.com )ÚsuperrFÚwriterE©Ú __class__rrrFps zMyProto.connection_made©r3r4r5rFÚ __classcell__rrrVrrSosrSc@s:eZdZdZd dd„Zdd„Zdd„Zdd „Zd d „ZdS) ÚMyDatagramProtoNcCs"d|_d|_|dur| ¡|_dSr7)r:r;r<r>r?rrrr@xszMyDatagramProto.__init__cCs||_d|_dS)NÚ INITIALIZED©r9r:rErrrrF~szMyDatagramProto.connection_madecCs|jt|ƒ7_dSrrG©r*rJÚaddrrrrÚdatagram_receivedƒsz!MyDatagramProto.datagram_receivedcCsdSrrr-rrrÚerror_received‡szMyDatagramProto.error_receivedcCsd|_|jr|j d¡dSrOrQr-rrrrRŠszMyDatagramProto.connection_lost)N) r3r4r5r>r@rFr_r`rRrrrrrZus  rZc@s:eZdZdZd dd„Zdd„Zdd„Zdd „Zd d „ZdS) ÚMyReadPipeProtoNcCs*dg|_d|_d|_|dur&| ¡|_dSr7)r:r;r9r<r>r?rrrr@”s zMyReadPipeProto.__init__cCs||_|j d¡dSrA)r9r:ÚappendrErrrrF›szMyReadPipeProto.connection_madecCs|jt|ƒ7_dSrrGrIrrrrK szMyReadPipeProto.data_receivedcCs|j d¡dSrL)r:rbr0rrrrN¤szMyReadPipeProto.eof_receivedcCs8d|jvr|j d¡|j d¡|jr4|j d¡dS)NrMrP)r:rbr>rDr-rrrrR¨s    zMyReadPipeProto.connection_lost)N) r3r4r5r>r@rFrKrNrRrrrrra‘s  rac@s*eZdZdZddd„Zdd„Zdd„ZdS) ÚMyWritePipeProtoNcCs"d|_d|_|dur| ¡|_dS)Nr8)r:r9r<r>r?rrrr@´szMyWritePipeProto.__init__cCs||_d|_dSrAr\rErrrrFºsz MyWritePipeProto.connection_madecCsd|_|jr|j d¡dSrOrQr-rrrrR¿sz MyWritePipeProto.connection_lost)N)r3r4r5r>r@rFrRrrrrrc±s rcc@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)ÚMySubprocessProtocolcsjd|_d|_ˆ ¡|_ˆ ¡|_‡fdd„tdƒDƒ|_dddœ|_d|_t j ˆdt j ˆddœ|_ dS)Nr8csi|]}|ˆ ¡“qSr)r<)Ú.0Úfd©r'rrÚ Íóz1MySubprocessProtocol.__init__..éri©éérg) r:r9r<r=Ú completedÚrangeÚ disconnectsrJÚ returncoderÚEventÚgot_datar?rrgrr@Ès     ÿzMySubprocessProtocol.__init__cCs||_d|_|j d¡dSrArCrErrrrFÓsz$MySubprocessProtocol.connection_madecCsd|_|j d¡dSrO)r:rnrDr-rrrrRÙsz$MySubprocessProtocol.connection_lostcCs$|j||7<|j| ¡dSr)rJrsÚset)r*rfrJrrrÚpipe_data_receivedÞsz'MySubprocessProtocol.pipe_data_receivedcCs*|r|j| |¡n|j| |¡dSr)rpÚ set_exceptionrD)r*rfr.rrrÚpipe_connection_lostãsz)MySubprocessProtocol.pipe_connection_lostcCs|j ¡|_dSr)r9Zget_returncoderqr0rrrÚprocess_exitedêsz#MySubprocessProtocol.process_exitedN) r3r4r5r@rFrRrurwrxrrrrrdÆs  rdcs0eZdZ‡fdd„Z‡fdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Ze eedƒd¡dd„ƒZe eedƒd ¡d!d"„ƒZe eedƒd ¡d#d$„ƒZdœd&d'„Zd(d)„Zejd*d+„ƒZd%d,ifd-d.„Zdd/d0„Zdžd1d2„Ze e d,ud3¡d4d5„ƒZ!eje e d,ud3¡d6d7„ƒƒZ"d8d9„Z#d:d;„Z$dŸdd?„ƒZ&d@dA„Z'e( )dB¡dCdD„ƒZ*dEdF„Z+dGdH„Z,dIdJ„Z-e ee.dKƒdL¡dMdN„ƒZ/dOdP„Z0ejdQdR„ƒZ1e ee.dSƒdT¡dUdV„ƒZ2d dWdX„Z3d¡dYdZ„Z4d¢d[d\„Z5e e d,ud3¡d]d^„ƒZ6eje e d,ud3¡d_d`„ƒƒZ7e e d,ud3¡dadb„ƒZ8eje e d,ud3¡dcdd„ƒƒZ9e e d,ud3¡dedf„ƒZ:eje e d,ud3¡dgdh„ƒƒZ;e e d,ud3¡didj„ƒZe ej?do¡dpdq„ƒZ@drds„ZAdtdu„ZBdvdw„ZCe ej?do¡dxdy„ƒZDdzd{„ZEd|d}„ZFe eGjHd~kd¡d€d„ƒZIe eGjHd~kd¡d‚dƒ„ƒZJe eGjHd~kd¡d„d…„ƒZKe eGjHd~kd¡d†d‡„ƒZLe eGjHd~kd¡dˆd‰„ƒZMe eGjHd~kd¡eN OdŠd‹¡dŒd„ƒƒZPe eGjHd~kd¡eN OdŠd‹¡dŽd„ƒƒZQdd‘„ZRd’d“„ZSd”d•„ZTd–d—„ZUd˜d™„ZVdšd›„ZW‡ZXS)£ÚEventLoopTestsMixincs$tƒ ¡| ¡|_| |j¡dSr)rTÚsetUpÚcreate_event_loopr'r%r0rVrrrzñs  zEventLoopTestsMixin.setUpcs4|j ¡st |j¡| ¡t ¡tƒ ¡dSr) r'Ú is_closedÚ test_utilsÚ run_brieflyZ doCleanupsr Ú gc_collectrTÚtearDownr0rVrrr€ös   zEventLoopTestsMixin.tearDowncsZdd„‰‡‡fdd„}ˆ td¡$ˆ tˆjj|ƒ¡Wdƒn1sL0YdS)NcÓst d¡IdHdS©Nr)rÚsleeprrrrÚcoro1szBEventLoopTestsMixin.test_run_until_complete_nesting..coro1c“s"ˆ ˆj ¡¡ˆj ˆƒ¡dSr)Ú assertTruer'Ú is_runningr&r©rƒr*rrÚcoro2szBEventLoopTestsMixin.test_run_until_complete_nesting..coro2zcoroutine \S+ was never awaited)ZassertWarnsRegexÚRuntimeWarningÚ assertRaisesÚ RuntimeErrorr'r&)r*r‡rr†rÚtest_run_until_complete_nestingÿsþ ÿz3EventLoopTestsMixin.test_run_until_complete_nestingcCsR|j ¡}|j t d¡¡|j ¡}| d||ko@dkn||¡dS)Nçš™™™™™¹?g{®Gáz´?gš™™™™™é?)r'Útimer&rr‚r„)r*Út0Út1rrrÚtest_run_until_completes  z+EventLoopTestsMixin.test_run_until_completecs(‡fdd„}|ƒ}ˆ tˆjj|¡dS)Nc“sˆj ¡t d¡IdHdS)NrŒ)r'Ústoprr‚rr0rrÚcbs z?EventLoopTestsMixin.test_run_until_complete_stopped..cb)r‰rŠr'r&)r*r’Ztaskrr0rÚtest_run_until_complete_stoppeds  ÿz3EventLoopTestsMixin.test_run_until_complete_stoppedcs>g‰‡‡fdd„}ˆj d|d¡ˆj ¡ˆ ˆdg¡dS)Ncsˆ |¡ˆj ¡dSr©rbr'r‘©Úarg©Úresultsr*rrÚcallback#s z5EventLoopTestsMixin.test_call_later..callbackrŒz hello world)r'Ú call_laterÚ run_foreverÚ assertEqual©r*r™rr—rÚtest_call_later s  z#EventLoopTestsMixin.test_call_latercs>g‰‡‡fdd„}ˆj |dd¡ˆj ¡ˆ ˆdg¡dS)Ncsˆ ||f¡ˆj ¡dSrr”)Zarg1Zarg2r—rrr™.sz4EventLoopTestsMixin.test_call_soon..callbackr"Úworld)r"rŸ)r'Ú call_soonr›rœrrr—rÚtest_call_soon+s  z"EventLoopTestsMixin.test_call_sooncsžg‰t ¡‰‡‡fdd„‰‡‡‡fdd„}ˆ ¡tj|d}| ¡ˆ(ˆj ˆd¡ˆj ¡Wdƒn1sx0Y| ¡ˆ  ˆddg¡dS)Ncs$ˆ |¡tˆƒdkr ˆj ¡dS©Nrm©rbrHr'r‘r•r—rrr™:s  z?EventLoopTestsMixin.test_call_soon_threadsafe..callbackcsˆj ˆd¡ˆ ¡dSr!)r'Úcall_soon_threadsafeÚreleaser)r™Úlockr*rrÚ run_in_thread?szDEventLoopTestsMixin.test_call_soon_threadsafe..run_in_thread©ÚtargetrŸr") Ú threadingÚLockÚacquireÚThreadÚstartr'r r›Újoinrœ)r*r§Útr)r™r¦r˜r*rÚtest_call_soon_threadsafe6s (z-EventLoopTestsMixin.test_call_soon_threadsafecsLg‰‡‡fdd„}ˆj |d¡ˆj |d¡ˆj ¡ˆ ˆddg¡dS)Ncs$ˆ |¡tˆƒdkr ˆj ¡dSr¢r£r•r—rrr™Ps  zKEventLoopTestsMixin.test_call_soon_threadsafe_same_thread..callbackr"rŸ)r'r¤r r›rœrrr—rÚ%test_call_soon_threadsafe_same_threadMs  z9EventLoopTestsMixin.test_call_soon_threadsafe_same_threadcCsHdd„}|j d|d¡}|j |¡\}}| |d¡| |t ¡¡dS)NcSs |t ¡fSr)rªÚ get_identr•rrrÚrun[sz5EventLoopTestsMixin.test_run_in_executor..runZyo)r'Úrun_in_executorr&rœZassertNotEqualrªr³)r*r´Úf2ÚresZ thread_idrrrÚtest_run_in_executorZs  z(EventLoopTestsMixin.test_run_in_executorcsrd‰‡fdd„}dd„}|j d|¡}| ¡|j |j ¡¡|j ¡||j_||j_t  d¡|  ˆ¡dS)NFcsd‰dS©NTr©Úargs©ZcalledrrÚpatched_call_sooneszJEventLoopTestsMixin.test_run_in_executor_cancel..patched_call_sooncSst d¡dS)Ngš™™™™™©?)rr‚rrrrr´isz.rungš™™™™™Ù?) r'rµÚcancelr&Zshutdown_default_executorr1r r¤rr‚Ú assertFalse)r*r½r´r¶rr¼rÚtest_run_in_executor_cancelbs ÿ  z/EventLoopTestsMixin.test_run_in_executor_cancelcsÂt ¡\‰}ˆ d¡tƒ‰‡‡‡fdd„}ˆj ˆ ¡|¡ˆj |jd¡t   ˆj‡fdd„¡ˆj |jd¡t   ˆj‡fdd„¡ˆj |j ¡ˆj ˆjj ¡ˆj  ¡ˆ ˆd ¡dS) NFcsVzˆ d¡}Wnty"YdS0|r4ˆ |¡nˆ ˆj ˆ ¡¡¡ˆ ¡dS©Né)ÚrecvÚBlockingIOErrorÚextendr„r'Ú remove_readerÚfilenor1©rJ©Ú bytes_readÚrr*rrÚreader{s  z8EventLoopTestsMixin.test_reader_callback..readersabccs tˆƒdkS)Nrj©rHr©rÊrrÚŠriz:EventLoopTestsMixin.test_reader_callback..sdefcs tˆƒdkS)NérÍrrÎrrrÏŒrisabcdef)ÚsocketÚ socketpairÚ setblockingÚ bytearrayr'Ú add_readerrÇr r,r}Ú run_untilr1r‘r›rœ)r*ÚwrÌrrÉrÚtest_reader_callbackvs    z(EventLoopTestsMixin.test_reader_callbackcs¤t ¡\}‰ˆ d¡‡‡fdd„}d}ˆj ˆ ¡||¡ˆj ¡ˆ ˆj ˆ ¡¡¡ˆ  ˆj ˆ ¡¡¡ˆ  ¡|  t |ƒd¡}|  ¡ˆ  ||¡dS)NFcsˆ |¡ˆj ¡dSr)r,r'r‘rÈ©r*r×rrÚwriter–s z8EventLoopTestsMixin.test_writer_callback..writersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrm)rÑrÒrÓr'Ú add_writerrÇr›r„Ú remove_writerr¿r1rÃrHrœ)r*rËrÚrJÚreadrrÙrÚtest_writer_callback’s   z(EventLoopTestsMixin.test_writer_callbackÚSIGKILLz No SIGKILLcsXd‰‡fdd„}| t|jjd|¡| t|jjd¡| t|jjtjd|¡| t|jjtjd¡| t|jjd|¡| t|jjd¡| t|jjd|¡| t|jjd¡| t|jjtj |¡|  |j tj ¡¡|j tj |¡t   t  ¡tj ¡t |j‡fdd„¡| |j tj ¡¡| t tj ¡tj¡|  |j tj ¡¡dS) Nrcs ˆd7‰dS©Nrlrr©ÚcaughtrrÚ my_handlerªsz?EventLoopTestsMixin.test_add_signal_handler..my_handlerZboomrléÿÿÿÿcsˆSrrrrárrrÏÉriz=EventLoopTestsMixin.test_add_signal_handler..)r‰Ú TypeErrorr'Úadd_signal_handlerÚremove_signal_handlerÚ ValueErrorÚsignalÚNSIGrŠrßr¿ÚSIGINTÚosÚkillÚgetpidr}rÖr„rœÚ getsignalÚdefault_int_handler©r*rãrrárÚtest_add_signal_handler¦sP  ÿ ÿþÿ ÿ ÿ ÿ ÿ þÿz+EventLoopTestsMixin.test_add_signal_handlerÚSIGALRMz No SIGALRMcs^d‰‡‡fdd„}ˆj tj|¡t tjdd¡ˆj dˆjj¡ˆj ¡ˆ  ˆd¡dS)Nrcsˆd7‰ˆj ¡dSrà)r'r‘r©râr*rrrã×szLEventLoopTestsMixin.test_signal_handling_while_selecting..my_handlerç{®Gáz„?é<rl© r'ræréróÚ setitimerÚ ITIMER_REALršr‘r›rœrñrrôrÚ$test_signal_handling_while_selectingÒs z8EventLoopTestsMixin.test_signal_handling_while_selectingcsld‰d‰‡‡‡fdd„}ˆjjtj|gˆ¢RŽt tjdd¡ˆj dˆjj¡ˆj ¡ˆ  ˆd¡dS)N)é*rcs"ˆd7‰ˆ |ˆ¡ˆj ¡dSrà)rœr'r‘rº©râr*Z some_argsrrrãès zAEventLoopTestsMixin.test_signal_handling_args..my_handlerrŒrörlr÷rñrrürÚtest_signal_handling_argsãs z-EventLoopTestsMixin.test_signal_handling_argsTcCsv|j |¡\}}| |tj¡| |tj¡| |j|¡|rN| |  d¡¡|j |j ¡|  |j d¡|  ¡dS)NÚsocknamer)r'r&ÚassertIsInstancerÚ TransportÚProtocolÚassertIsr9ÚassertIsNotNoneÚget_extra_infor>Ú assertGreaterr;r1)r*Úconnection_futÚcheck_socknameÚtrÚprrrrÚ_basetest_create_connectionõsz/EventLoopTestsMixin._basetest_create_connectioncsTt ¡8}ˆjj‡fdd„g|j¢RŽ}ˆ |¡Wdƒn1sF0YdS)Ncs tˆjdS©Nrg©rSr'rr0rrrÏriz.)r}Úrun_test_serverr'Úcreate_connectionÚaddressr )r*ÚhttpdÚconn_futrr0rÚtest_create_connections  ÿÿz*EventLoopTestsMixin.test_create_connectioncsXtƒ }t ¡4}ˆj ‡fdd„|j¡}ˆ ||¡Wdƒn1sJ0YdS)Ncs tˆjdSr r rr0rrrÏrizAEventLoopTestsMixin.test_create_unix_connection..)r r}Úrun_test_unix_serverr'Úcreate_unix_connectionrr )r*rrrrr0rÚtest_create_unix_connections  ÿz/EventLoopTestsMixin.test_create_unix_connectionNcCs|r| | d¡¡|r,| || d¡¡n| | d¡¡| || d¡¡| d¡}| |t¡| t|ƒd|¡| |dt¡| |dt¡| |dt¡| d ¡}| |¡| | ¡| d ¡¡| |  ¡| d¡¡| |  ¡| d¡¡| | ¡| d ¡¡dS) NrþÚpeernameÚpeercertÚcipherrjrrlrmZ ssl_objectÚ compression) rrrœrÿrrHÚstrrrrZ getpeercert)r*ÚclientrrrrZsslobjrrrÚcheck_ssl_extra_infos<ÿÿ     ÿ ÿ ÿ ÿz(EventLoopTestsMixin.check_ssl_extra_infocCsx|j |¡\}}| |tj¡| |tj¡| d|jj  ¡v¡|  |||¡|j |j ¡|  |j d¡| ¡dS)NÚsslr)r'r&rÿrrrr„rWr3Úlowerrr>rr;r1)r*rrrrr rrrÚ_basetest_create_ssl_connection1sz3EventLoopTestsMixin._basetest_create_ssl_connectionc s|t ¡d}ˆ |||¡ttdƒr˜tjjfddddœ‡fdd„ }tjd|d6}|dd}ˆ |||¡ˆ  |j d ¡Wdƒn1sŽ0Yˆ  tj ¡P}|dd}t  ¡ˆ |||¡Wdƒn1sÜ0YWdƒn1sú0Yˆ  |jjd ¡dS) N©rÚPurpose)ÚcafileÚcapathÚcadatacsˆ |tjj¡t ¡S)z A ssl.create_default_context() replacement that doesn't enable cert validation. )rœrr!Ú SERVER_AUTHr}Údummy_ssl_context)Zpurposer"r#r$r0rrÚ_dummy_ssl_create_contextEszREventLoopTestsMixin._test_create_ssl_connection.._dummy_ssl_create_contextzssl.create_default_context)Ú side_effectTrlZCERTIFICATE_VERIFY_FAILED)r}r&rÚhasattrrr!r%rÚpatchrœZ call_countr‰ÚSSLErrorÚdisable_loggerÚ exceptionÚreason) r*rrrrrr'ÚmÚcmrr0rÚ_test_create_ssl_connection=s2ÿ þ ÿ ÿ,  ÿ@z/EventLoopTestsMixin._test_create_ssl_connectionz No ssl modulecsdtjddD}tjˆjj‡fdd„g|j¢RŽ}ˆj|||jdWdƒn1sV0YdS)NT©Zuse_sslcs tˆjdSr r rr0rrrÏgriz@EventLoopTestsMixin.test_create_ssl_connection..©r)r}r Ú functoolsÚpartialr'rrr1)r*rrrr0rÚtest_create_ssl_connectionbs þýÿz.EventLoopTestsMixin.test_create_ssl_connectioncsltƒ }tjddD}tjˆjj‡fdd„|jdd}ˆj||||jdWdƒn1s^0YdS)NTr2cs tˆjdSr r rr0rrrÏvrizEEventLoopTestsMixin.test_create_ssl_unix_connection..ú 127.0.0.1)Úserver_hostnamer3) r r}rr4r5r'rrr1)r*rrrrr0rÚtest_create_ssl_unix_connectionlsýþz3EventLoopTestsMixin.test_create_ssl_unix_connectioncs–t ¡z}t ¡}ˆjj‡fdd„g|j¢Rd|jd|fiŽ}ˆj |¡\}}|j  d¡d}ˆ  ||¡|  ¡Wdƒn1sˆ0YdS)Ncs tˆjdSr r rr0rrrÏrizGEventLoopTestsMixin.test_create_connection_local_addr..Ú local_addrrrþrl) r}r r Úfind_unused_portr'rrr&r9rrœr1)r*rÚportÚfrr Zexpectedrr0rÚ!test_create_connection_local_addr}s  ÿþ þ z5EventLoopTestsMixin.test_create_connection_local_addrc s°t ¡”}ˆjj‡fdd„g|j¢Rd|jiŽ}ˆ t¡}ˆj |¡Wdƒn1s\0Yˆ |j j t j ¡ˆ  t |jƒ|j j¡Wdƒn1s¢0YdS)Ncs tˆjdSr r rr0rrrÏ‹rizNEventLoopTestsMixin.test_create_connection_local_addr_in_use..r:)r}r r'rrr‰ÚOSErrorr&rœr-ÚerrnoÚ EADDRINUSEÚassertInrÚstrerror)r*rr=r0rr0rÚ(test_create_connection_local_addr_in_useˆs  ÿþþ *z.MyProtocstƒ |¡ˆ ˆj¡dSr)rTrRr r‘r-)rWr'rrrR—s zQEventLoopTestsMixin.test_connect_accepted_socket..MyProto.connection_lostcstƒ |¡|j ˆ¡dSr)rTrKr9rUrI)rWÚexpected_responserrrK›s zOEventLoopTestsMixin.test_connect_accepted_socket..MyProto.data_received)r3r4r5rRrKrYr)rEr'rVrrS•srS©r7rrl)Úbacklogs test datasrogerc sxzDt ¡}ˆdurˆ |¡}| ˆ¡| ˆ¡| d¡‰| ¡Wn.tyr}ztd|ƒWYd}~n d}~00dS)Nécz8Failure in client thread in test_connect_accepted_socket)rÑZ wrap_socketÚconnectÚsendallrÃr1Ú ExceptionÚprint)Zcsockr.)r^Ú client_sslÚmessageÚresponserrr¦s     þz@EventLoopTestsMixin.test_connect_accepted_socket..clientT)r©ÚdaemonrgcsˆSrrr©ÚprotorrrϽrizBEventLoopTestsMixin.test_connect_accepted_socket..r rP)r'r6rÑÚ create_serverÚ getsocknamerªr­r®Úacceptr&Úconnect_accepted_socketr›r9r1r Ú join_threadr¿Úis_aliverœr:r;rH) r*Z server_sslrMrSZlsockrÚthreadÚconnÚ_r)r^rMrEr'rNrRrOrÚtest_connect_accepted_socket’s4   ÿÿ  z0EventLoopTestsMixin.test_connect_accepted_socketcCsLtjdkr,tjdkr,t|jtjƒr,t d¡‚t   ¡}t   ¡}|  ||¡dS)Nr)rjrz=SSL not supported with proactor event loops before Python 3.5) rrÚ version_infoÚ isinstancer'rZBaseProactorEventLoopÚunittestÚSkipTestr}Zsimple_server_sslcontextZsimple_client_sslcontextr\)r*Zserver_contextZclient_contextrrrÚ test_ssl_connect_accepted_socketÈs ÿ þÿz4EventLoopTestsMixin.test_ssl_connect_accepted_socketcCsdt ¡}| |j¡|jjt|tjd}| t d¡|j  |¡Wdƒn1sV0YdS)N)Zssl_handshake_timeoutz1ssl_handshake_timeout is only meaningful with ssl) rÑÚ addCleanupr1r'rVrSr ZLOOPBACK_TIMEOUTÚassertRaisesRegexrèr&)r*ÚsockÚcororrrÚ9test_connect_accepted_socket_ssl_timeout_for_plain_socket×s ÿþzMEventLoopTestsMixin.test_connect_accepted_socket_ssl_timeout_for_plain_socketzasyncio.base_events.socketc sʇfdd„‰‡‡fdd„}t|ƒ}ˆtjkrDdd„|Dƒ| ¡j_ndd„|Dƒ| ¡j_|ˆj_t ¡ˆj_ t ¡ˆj_ ˆj  ‡fdd „|d ¡}ˆj  |¡}ˆ  |j¡d d „|jDƒ}ˆ ||¡dS) NcŸs>ˆtjkr ˆtjdd||ffgSˆtjdd||ddffgSdS)NrÐÚr)rÑÚAF_INETÚ SOCK_STREAM)Úhostr<r»Úkw)ÚfamilyrrÚ getaddrinfoãs zEEventLoopTestsMixin.create_server_multiple_hosts..getaddrinfocsˆj ˆ|i|¤Ž¡Sr)r'Ú create_task)r»Úkwds)rmr*rrÚgetaddrinfo_taskészJEventLoopTestsMixin.create_server_multiple_hosts..getaddrinfo_taskcSsg|] }|df‘qS)éPr©rerjrrrÚ ïszDEventLoopTestsMixin.create_server_multiple_hosts..cSsg|]}|dddf‘qS)rqrrrrrrrrsòscs tˆjƒSrr rr0rrrÏ÷rizBEventLoopTestsMixin.create_server_multiple_hosts..rqcSsh|]}| ¡d’qS)r)Ú getsockbyname)rerdrrrÚ úrizCEventLoopTestsMixin.create_server_multiple_hosts..)rtrÑrhrtr(r'rmrÚMockZ_start_servingÚ _stop_servingrSr&rbr1Úsocketsrœ) r*rlZhostsZ mock_sockrpZ unique_hostsr=ÚserverZ server_hostsr)rlrmr*rÚcreate_server_multiple_hostsás$  ÿÿ    z0EventLoopTestsMixin.create_server_multiple_hostscCs| tjgd¢¡dS)N)ú1.2.3.4z5.6.7.8r{)rzrÑrhr0rrrÚ&test_create_server_multiple_hosts_ipv4ýsÿz:EventLoopTestsMixin.test_create_server_multiple_hosts_ipv4cCs| tjgd¢¡dS)N)ú::1z::2r})rzrÑÚAF_INET6r0rrrÚ&test_create_server_multiple_hosts_ipv6sÿz:EventLoopTestsMixin.test_create_server_multiple_hosts_ipv6cs&t|jƒ‰|j ‡fdd„dd¡}|j |¡}| t|jƒd¡|jd}| ¡\}}| |d¡t ¡}|  d|f¡|  d¡|j ˆj ¡| dˆj ¡t  |j‡fd d„¡| d ˆj¡| ˆj d ¡¡| dˆj d ¡d¡ˆj ¡|j ˆj¡| d ˆj ¡| ¡| ¡dS)NcsˆSrrrrQrrrÏriz8EventLoopTestsMixin.test_create_server..ú0.0.0.0rrlr7óxxxrBcs ˆjdkSr©r;rrQrrrÏrirjrþrrP)rSr'rSr&rœrHrxrTrÑrIrJr=r:r}rÖr;rr9rr1r>©r*r=ryrdrjr<rrrQrÚtest_create_servers.      ÿ z&EventLoopTestsMixin.test_create_serverÚ SO_REUSEPORTzNo SO_REUSEPORTcsät|jƒ‰|j ‡fdd„dd¡}|j |¡}| t|jƒd¡|jd}| | t j t j ¡¡|  ¡t  |j¡t|jƒ‰|jj‡fdd„dddd}|j |¡}| t|jƒd¡|jd}| | t j t j ¡¡|  ¡dS) NcsˆSrrrrQrrrÏ-rizCEventLoopTestsMixin.test_create_server_reuse_port..r€rrlcsˆSrrrrQrrrÏ:riT)Ú reuse_port)rSr'rSr&rœrHrxr¿Ú getsockoptrÑÚ SOL_SOCKETr…r1r}r~r„)r*r=ryrdrrQrÚtest_create_server_reuse_port)s6 ÿ  ÿÿ  ÿ  ÿÿz1EventLoopTestsMixin.test_create_server_reuse_portc sDt ¡‰| ‡fdd„¡|jj|ˆfi|¤Ž}|j |¡}|ˆfS)Ncstj ˆ¡ot ˆ¡Sr)rìÚpathÚexistsÚunlinkr©rŠrrrÏEriz7EventLoopTestsMixin._make_unix_server..)r}Zgen_unix_socket_pathrbr'Úcreate_unix_serverr&)r*ÚfactoryÚkwargsr=ryrrrÚ_make_unix_serverCs  z%EventLoopTestsMixin._make_unix_servercsÎt|jd‰| ‡fdd„¡\}}| t|jƒd¡t tj¡}| |¡|  d¡|j  ˆj ¡| dˆj ¡t  |j‡fdd„¡| dˆj¡ˆj ¡|j  ˆj¡| d ˆj ¡| ¡| ¡dS) NrgcsˆSrrrrQrrrÏOriz=EventLoopTestsMixin.test_create_unix_server..rlrrBcs ˆjdkSrr‚rrQrrrÏXrirjrP)rSr'r‘rœrHrxrÑÚAF_UNIXrIrJr&r=r:r}rÖr;r9r1r>)r*ryrŠrrrQrÚtest_create_unix_serverLs     z+EventLoopTestsMixin.test_create_unix_serverr’zNo UNIX Socketsc sŽt|jd‰t ¡}|b|jj‡fdd„d|d}| td¡|j |¡Wdƒn1sb0YWdƒn1s€0YdS)NrgcsˆSrrrrQrrrÏmrizOEventLoopTestsMixin.test_create_unix_server_path_socket_error..z/test©rdz3path and sock can not be specified at the same time)rSr'rÑrŽrcrèr&)r*rdr=rrQrÚ)test_create_unix_server_path_socket_errorhs ÿz=EventLoopTestsMixin.test_create_unix_server_path_socket_errorcCs,t tj¡}|jtjO_| ||¡|Sr)rÚ SSLContextZPROTOCOL_TLS_SERVERÚoptionsÚ OP_NO_SSLv2Zload_cert_chain)r*ÚcertfileÚkeyfileÚ sslcontextrrrÚ_create_ssl_contextss  z'EventLoopTestsMixin._create_ssl_contextc CsX| ||¡}|jj|dd|d}|j |¡}|jd}| ¡\}} | |d¡||| fS)Nr7rr )rœr'rSr&rxrTrœ) r*rr™ršr›r=ryrdrjr<rrrÚ_make_ssl_serverys     z$EventLoopTestsMixin._make_ssl_servercCs| ||¡}|j||dS)Nr )rœr‘)r*rr™ršr›rrrÚ_make_ssl_unix_server„s z)EventLoopTestsMixin._make_ssl_unix_servercsêt|jd‰| ‡fdd„tjtj¡\}}}|jjt||t ¡d}|j  |¡\}}|  d¡|j  ˆj ¡|  dˆj ¡t |j‡fdd„¡|  dˆj¡|j|||fd ˆj ¡|j  ˆj¡|  d ˆj ¡| ¡| ¡dS) NrgcsˆSrrrrQrrrÏŒriz.r rrBcs ˆjdkSrr‚rrQrrrÏ–rirjr3rP)rSr'rr}ÚONLYCERTÚONLYKEYrr6r&r&rUr=rœr:rÖr;rr9r1r>)r*ryrjr<Úf_crr rrQrÚtest_create_server_sslˆs& ÿ  ÿ  z*EventLoopTestsMixin.test_create_server_sslcsÖt|jd‰| ‡fdd„tjtj¡\}}|jjt|t ¡dd}|j  |¡\}}|  d¡|j  ˆj ¡|  dˆj ¡t |j‡fdd„¡|  d ˆj¡ˆj ¡|j  ˆj¡|  d ˆj ¡| ¡| ¡dS) NrgcsˆSrrrrQrrrÏ­rizAEventLoopTestsMixin.test_create_unix_server_ssl..rg©rr8rrBcs ˆjdkSrr‚rrQrrrϸrirjrP)rSr'ržr}rŸr rr6r&r&rUr=rœr:rÖr;r9r1r>)r*ryrŠr¡rr rrQrÚtest_create_unix_server_ssl¨s& ÿ þ  z/EventLoopTestsMixin.test_create_unix_server_sslc s(t|jd‰| ‡fdd„tj¡\}}}t tj¡}|jtj O_tj |_ t |dƒr\d|_ |jjt|||d}tj |jd¡~t ¡J| tjd¡|j |¡Wdƒn1s¼0YWdƒn1sÚ0Yt |j¡Wdƒn1s0Y| ˆj¡| ¡dS) NrgcsˆSrrrrQrrrÏËrizJEventLoopTestsMixin.test_create_server_ssl_verify_failed..Úcheck_hostnameTr Úcall_exception_handlerú(?i)certificate.verify.failed)rSr'rr}ÚSIGNED_CERTFILErr–ÚPROTOCOL_TLS_CLIENTr—r˜Ú CERT_REQUIREDÚ verify_moder)r¥rrr*Úobjectr,rcr+r&r~Ú assertIsNoner9r1©r*ryrjr<Ússlcontext_clientr¡rrQrÚ$test_create_server_ssl_verify_failedÇs* ÿ    ÿ ÿH, z8EventLoopTestsMixin.test_create_server_ssl_verify_failedc s&t|jd‰| ‡fdd„tj¡\}}t tj¡}|jtj O_tj |_ t |dƒrZd|_ |jjt||dd}tj |jd¡~t ¡J| tjd ¡|j |¡Wdƒn1sº0YWdƒn1sØ0Yt |j¡Wdƒn1s0Y| ˆj¡| ¡dS) NrgcsˆSrrrrQrrrÏérizOEventLoopTestsMixin.test_create_unix_server_ssl_verify_failed..r¥TÚinvalidr£r¦r§)rSr'ržr}r¨rr–r©r—r˜rªr«r)r¥rrr*r¬r,rcr+r&r~r­r9r1)r*ryrŠr¯r¡rrQrÚ)test_create_unix_server_ssl_verify_failedäs, ÿ   þ ÿH, z=EventLoopTestsMixin.test_create_unix_server_ssl_verify_failedc s*t|jd‰| ‡fdd„tj¡\}}}t tj¡}|jtj O_tj |_ |j tj dt|dƒrjd|_|jjt|||d}tj |jd¡rt ¡J| tjd ¡|j |¡Wdƒn1sÊ0YWdƒn1sè0YWdƒn1s0Y| ˆj¡| ¡dS) NrgcsˆSrrrrQrrrÏrizIEventLoopTestsMixin.test_create_server_ssl_match_failed..©r"r¥Tr r¦z=IP address mismatch, certificate is not valid for '127.0.0.1')rSr'rr}r¨rr–r©r—r˜rªr«Úload_verify_locationsÚ SIGNING_CAr)r¥rrr*r¬r,rcZCertificateErrorr&r­r9r1r®rrQrÚ#test_create_server_ssl_match_faileds0 ÿ  ÿ  ÿ þh z7EventLoopTestsMixin.test_create_server_ssl_match_failedcsÆt|jd‰| ‡fdd„tj¡\}}t tj¡}|jtj O_tj |_ |j tj dt|dƒrhd|_|jjt||dd}|j |¡\}}|j ˆj¡ˆj ¡| ¡| ¡|j ˆj¡dS) NrgcsˆSrrrrQrrrÏ%rizJEventLoopTestsMixin.test_create_unix_server_ssl_verified..r³r¥TÚ localhostr£)rSr'ržr}r¨rr–r©r—r˜rªr«r´rµr)r¥rr&r=r9r1r>)r*ryrŠr¯r¡rr rrQrÚ$test_create_unix_server_ssl_verified s( ÿ   þ z8EventLoopTestsMixin.test_create_unix_server_ssl_verifiedcsàt|jd‰| ‡fdd„tj¡\}}}t tj¡}|jtj O_tj |_ |j tj dt|dƒrjd|_|jjt|||dd}|j |¡\}}|j ˆj¡|j|||ftjd ˆj ¡| ¡| ¡|j ˆj¡dS) NrgcsˆSrrrrQrrrÏ?rizEEventLoopTestsMixin.test_create_server_ssl_verified..r³r¥Tr·r£)rr)rSr'rr}r¨rr–r©r—r˜rªr«r´rµr)r¥rr&r=rZPEERCERTr9r1r>)r*ryrjr<r¯r¡rr rrQrÚtest_create_server_ssl_verified;s. ÿ    þ ÿ z3EventLoopTestsMixin.test_create_server_ssl_verifiedc s®|j ¡‰G‡fdd„dtƒ}t d¡}|jj||d}|j |¡}|jd}| | ¡| ¡¡|  ¡\}}| |d¡t ¡}|  d|f¡|  d¡|  ¡|  ¡dS) NcseZdZ‡‡fdd„Z‡ZS)z@EventLoopTestsMixin.test_create_server_sock..TestMyProtocstƒ |¡ˆ |¡dSr©rTrFrDrE)rWrRrrrF]s zPEventLoopTestsMixin.test_create_server_sock..TestMyProto.connection_maderXrrQrVrÚ TestMyProto\sr»©r€rr”rr€r7r) r'r<rSrÑrSr&rxrœrÇrTrIr,r1) r*r»Úsock_obr=ryrdrjr<rrrQrÚtest_create_server_sockYs       z+EventLoopTestsMixin.test_create_server_sockcCs¢t d¡}|jjt|d}|j |¡}|jd}| ¡\}}|jjt||d}| t¡}|j |¡Wdƒn1sz0Y|  |j j t j ¡|  ¡dS)Nr¼r”r©rjr<)rÑrSr'rSr&rxrTr‰r?rœr-r@rAr1)r*r½r=ryrdrjr<r0rrrÚtest_create_server_addr_in_useps     *z2EventLoopTestsMixin.test_create_server_addr_in_usezIPv6 not supported or enabledc s<|j ¡‰G‡fdd„dtƒ}d}z*t ¡}|jj|d|d}|j |¡}Wq¦ty }z<|jtj krŠ|d7}|  d|¡WYd}~q"n‚WYd}~q"d}~00q¦q"t   ¡}|  d|f¡|  d¡|j ˆ¡}|j ¡| ¡|j ¡‰t   t j¡}|  d |f¡|  d¡|j ˆ¡}|j ¡| ¡| ¡dS) NcseZdZ‡‡fdd„Z‡ZS)zFEventLoopTestsMixin.test_create_server_dual_stack..TestMyProtocstƒ |¡ˆ |¡dSrrºrE)rWÚf_protorrrF„s zVEventLoopTestsMixin.test_create_server_dual_stack..TestMyProto.connection_maderXr©rÁrVrr»ƒsr»rr¿rlrr7rr})r'r<rSr r;rSr&r?r@rAZassertGreaterEqualrÑrIr,r9r1r~) r*r»Z try_countr<r=ryÚexrrRrrÂrÚtest_create_server_dual_stacks8           z1EventLoopTestsMixin.test_create_server_dual_stackcCsŠ|j tdd¡}|j |¡}|jd}| ¡\}}t ¡}| d|f¡| d¡|  ¡|  ¡t ¡}|  t |jd|f¡|  ¡dS)Nr€rr7r) r'rSrSr&rxrTrÑrIr,r1r‰ÚConnectionRefusedErrorrƒrrrÚtest_server_close¨s     ÿz%EventLoopTestsMixin.test_server_closec s„G‡fdd„dtƒ}ˆjj|||d}ˆj |¡\}‰| d¡}t |tjtjB¡\}}ˆ  |t j ¡ˆ  ˆ|¡ˆ  dˆj ¡ˆ ˆj|¡ˆjj‡fdd„||fd}ˆj |¡\} ‰ˆ  | t j ¡ˆ  ˆt¡ˆ  dˆj ¡ˆ ˆj| ¡|  d ¡t ˆj‡fd d„¡ˆ  d ˆj¡t ˆj‡fd d„¡ˆ  d ˆj¡ˆ |  d¡¡|  ¡ˆj ˆj¡ˆ  dˆj ¡ˆj ¡dS)Ncs*eZdZ‡‡fdd„Z‡fdd„Z‡ZS)zOEventLoopTestsMixin._test_create_datagram_endpoint..TestMyDatagramProtocstƒjˆjddSr )rTr@r')Z inner_self)rWr*rrr@¼szXEventLoopTestsMixin._test_create_datagram_endpoint..TestMyDatagramProto.__init__cs$tƒ ||¡|j d||¡dS)Nsresp:)rTr_r9Úsendtor]rVrrr_¿szaEventLoopTestsMixin._test_create_datagram_endpoint..TestMyDatagramProto.datagram_received)r3r4r5r@r_rYrr0rVrÚTestMyDatagramProto»srÈ)r:rlrþr[cs tˆjdSr ©rZr'rr0rrrÏÐrizDEventLoopTestsMixin._test_create_datagram_endpoint..)Z remote_addrrcsˆjSrr‚r)ryrrrÏÚrirjcsˆjSrr‚r)rrrrÏÜriérP)rZr'Úcreate_datagram_endpointr&rrÑÚ getnameinfoÚNI_NUMERICHOSTÚNI_NUMERICSERVrÿrrrœr:rr9rÇr}rÖr;rr1r>) r*r:rlrÈreZ s_transportrþrjr<r9r)rr*ryrÚ_test_create_datagram_endpointºs@ÿ  ÿ  þ  z2EventLoopTestsMixin._test_create_datagram_endpointcCs| dtj¡dS)NrF)rÏrÑrhr0rrrÚtest_create_datagram_endpointêsz1EventLoopTestsMixin.test_create_datagram_endpointcCs| dtj¡dS)N)r}r)rÏrÑr~r0rrrÚ"test_create_datagram_endpoint_ipv6ísz6EventLoopTestsMixin.test_create_datagram_endpoint_ipv6c sÎd}d}ˆj ˆjj|dtjiŽ¡}|D]H\}}}}}z(tj|||d}| d¡| |¡Wn Yq(0qrq(ˆjj‡fdd„|d} ˆj | ¡\} } ˆ | t j ¡ˆ | t ¡|   ¡ˆj | j ¡dS)NrFÚtype)rlrÒrRFcs tˆjdSr rÉrr0rrrÏrizHEventLoopTestsMixin.test_create_datagram_endpoint_sock..r”)r'r&rmrÑÚ SOCK_DGRAMrÓÚbindrËrÿrrrZr1r>) r*rdZ local_addressZinfosrlrÒrRZcnamerr=rr rr0rÚ"test_create_datagram_endpoint_sockñs2ÿÿÿ  ÿ z6EventLoopTestsMixin.test_create_datagram_endpoint_sockcCsf| ¡}t|tjƒs&| ¡| d¡| d|j¡| ¡| d|j¡| |j ¡| |j ¡dS)Nz#loop is not a BaseSelectorEventLooprlr) r{r^rZBaseSelectorEventLoopr1ZskipTestrœZ _internal_fdsr­Z_csockZ_ssockr?rrrÚtest_internal_fds s   z%EventLoopTestsMixin.test_internal_fdsrzDon't support pipes for Windowscsötˆjd‰t ¡\}}t |dd¡‰‡‡‡fdd„}ˆj |ƒ¡t |d¡t  ˆj‡fdd„¡ˆ  d ˆj ¡t |d ¡t  ˆj‡fd d„¡ˆ  d d gˆj ¡ˆ  dˆj ¡t  |¡ˆj ˆj¡ˆ  gd¢ˆj ¡ˆ ˆj d¡¡dS)NrgÚrbrÂc“s^ˆj ‡fdd„ˆ¡IdH\}}ˆ |ˆ¡ˆ |ˆj¡ˆ ddgˆj¡ˆ dˆj¡dS)NcsˆSrrrrQrrrÏ!rizEEventLoopTestsMixin.test_read_pipe..connect..r8rBr©r'Úconnect_read_piperr9rœr:r;©r°Úp©ÚpipeobjrRr*rrrIs ÿ z3EventLoopTestsMixin.test_read_pipe..connectó1cs ˆjdkSràr‚rrQrrrÏ*riz4EventLoopTestsMixin.test_read_pipe..rló2345cs ˆjdkS©Nrr‚rrQrrrÏ.rir8rBr©r8rBrMrPÚpipe)rar'rìrâÚioÚopenr&rUr}rÖrœr;r:r1r>rr9r)r*ÚrpipeÚwpiperIrrÜrÚtest_read_pipes$      ÿz"EventLoopTestsMixin.test_read_pipecs°| ¡‰tˆd‰tˆd‰t ¡\}}t |dd¡‰t |dd¡‰‡‡‡‡‡fdd„}ˆ |ƒ¡\}}ˆ ¡|  dt |ƒ¡|  dt |ƒ¡ˆ ¡ˆ ¡d|_ d|_ dS)Nrgr×rÂr×c“sDˆ ‡fdd„ˆ¡IdH\}}ˆ ‡fdd„ˆ¡IdH\}}||fS)NcsˆSrrr©Ú read_protorrrÏGrizSEventLoopTestsMixin.test_unclosed_pipe_transport..connect..csˆSrrr©Ú write_protorrrÏIri)rÙÚconnect_write_pipe)Úread_transportr[Úwrite_transport©r'réZrpipeobjZwpipeobjrërrrIEs ÿ ÿzAEventLoopTestsMixin.test_unclosed_pipe_transport..connecträ) r{rarcrìrârãrär&r1rBÚreprZ_pipe)r*rårærIrírîrrïrÚtest_unclosed_pipe_transport9s   z0EventLoopTestsMixin.test_unclosed_pipe_transportcstˆjd‰t ¡\}}t |dd¡‰‡‡‡fdd„}ˆj |ƒ¡t |d¡t  ˆj‡fdd„¡ˆ  d ˆj ¡t |d ¡t  ˆj‡fd d„¡ˆ  d d gˆj ¡ˆ  dˆj ¡t  |¡ˆj  ¡ˆj ˆj¡ˆ  gd¢ˆj ¡ˆ ˆj d¡¡dS)Nrgr×rc“s^ˆj ‡fdd„ˆ¡IdH\}}ˆ |ˆ¡ˆ |ˆj¡ˆ ddgˆj¡ˆ dˆj¡dS)NcsˆSrrrrQrrrÏdrizKEventLoopTestsMixin.test_read_pty_output..connect..r8rBrrØrÚ©Zmaster_read_objrRr*rrrIcsÿ z9EventLoopTestsMixin.test_read_pty_output..connectrÞcsˆjSrr‚rrQrrrÏnriz:EventLoopTestsMixin.test_read_pty_output..rlrßcs ˆjdkSràr‚rrQrrrÏrrir8rBrrárâ)rar'rìÚopenptyrãrär&rUr}rÖrœr;r:r1r9r>rr)r*ÚmasterÚslaverIrròrÚtest_read_pty_output[s&       ÿz(EventLoopTestsMixin.test_read_pty_outputcs6t ¡\‰}t |dd¡}t|jd‰|j ‡fdd„|¡}|j |¡\}}| |ˆ¡| |ˆj ¡|  dˆj ¡|  d¡t ƒ‰‡fdd „‰t |j‡‡fd d„¡|  dˆ¡|  d ¡t |j‡‡fd d„¡|  d ˆ¡|  dˆj ¡t ˆ¡| ˆj  d¡¡ˆj  ¡|j ˆj¡|  dˆj ¡dS)NÚwbrÂrgcsˆSrrrrQrrrÏ…riz5EventLoopTestsMixin.test_write_pipe..rBrÞcst ˆd¡}||7}t|ƒSrÁ©rìrÝrH©rJÚchunk)rårrrÌŽs z3EventLoopTestsMixin.test_write_pipe..readercs ˆˆƒdkSràrr©rJrÌrrrÏ“rirßcs ˆˆƒdkSràrrrûrrrÏ—rió12345rârP)rìrârãrärcr'rìr&rr9rœr:rUrÔr}rÖr1rrr>)r*rærÝrIr9rÛr)rJrRrÌrårÚtest_write_pipe~s,          z#EventLoopTestsMixin.test_write_pipecsÖt ¡\}}| d¡t | ¡dd¡}t|jd‰|j ‡fdd„|¡}|j  |¡\}}|  |ˆ¡|  |ˆj ¡|  dˆj ¡| d¡|j  |j |d¡¡}|  d|¡| ¡|j  ˆj¡|  d ˆj ¡dS) NFr÷rÂrgcsˆSrrrrQrrrÏ­rizIEventLoopTestsMixin.test_write_pipe_disconnect_on_close..rBrÞrP)rÑrÒrÓrãräÚdetachrcr'rìr&rr9rœr:rUÚ sock_recvr1r>)r*ZrsockZwsockrÝrIr9rÛrJrrQrÚ#test_write_pipe_disconnect_on_close¥s      z7EventLoopTestsMixin.test_write_pipe_disconnect_on_closerrÐcsBt ¡\‰}t |dd¡}t|jd‰|j ‡fdd„|¡}|j |¡\}}| |ˆ¡| |ˆj ¡|  dˆj ¡|  d¡t ƒ‰‡fdd „‰tj|j‡‡fd d„tjd |  dˆ¡|  d ¡tj|j‡‡fd d„tjd |  dˆ¡|  dˆj ¡t ˆ¡| ˆj  d¡¡ˆj  ¡|j ˆj¡|  dˆj ¡dS)Nr÷rrgcsˆSrrrrQrrrÏÆriz4EventLoopTestsMixin.test_write_pty..rBrÞcst ˆd¡}||7}t|ƒSrÁrørù©rôrrrÌÏs z2EventLoopTestsMixin.test_write_pty..readercs ˆˆƒdkSràrrrûrrrÏÔri©Útimeoutrßcs ˆˆƒdkSràrrrûrrrÏÙrirürârP)rìrórãrärcr'rìr&rr9rœr:rUrÔr}rÖr Ú SHORT_TIMEOUTr1rrr>)r*rõÚslave_write_objrIr9rÛr)rJrôrRrÌrÚtest_write_pty¼s4     ÿ  ÿ   z"EventLoopTestsMixin.test_write_ptyc sÂt ¡\‰}t |¡}t |¡t |dd¡}t|jd‰|j  ‡fdd„|¡}|j  |¡\}}|  |ˆ¡|  |ˆj ¡|  ddgˆj¡|  dˆj¡t |dd¡}t|jd‰|j ‡fd d„|¡}|j  |¡\} }|  |ˆ¡|  | ˆj ¡|  dˆj¡tƒ‰‡fd d „‰|  d ¡tj|j‡‡fd d„tjd|  d ˆ¡|  ddgˆj¡|  dˆj¡t ˆd¡tj|j‡fdd„tjd|  ddgˆj¡|  dˆj¡|  dˆj¡|  d¡tj|j‡‡fdd„tjd|  dˆ¡|  ddgˆj¡|  dˆj¡t ˆd¡tj|j‡fdd„tjd|  ddgˆj¡|  dˆj¡|  dˆj¡t ˆ¡| ¡|j  ˆj¡|  gd¢ˆj¡|  ¡|j  ˆj¡|  dˆj¡dS)Nr×rrgcsˆSrrrrèrrrÏôriz.r8rBr÷csˆSrrrrêrrrÏÿricst ˆd¡}||7}t|ƒSrÁrørùrrrrÌs z:EventLoopTestsMixin.test_bidirectional_pty..readerrÞcs ˆˆƒdkSràrrrûrrrÏ riróacs ˆjdkSràr‚rrèrrrÏrirlrßcs ˆˆƒdkSràrrrûrrrÏrirüsbcdecs ˆjdkSràr‚rrèrrrÏ"rirrárP)rìróÚdupÚttyZsetrawrãrärar'rÙr&rr9rœr:r;rcrìrÔrUr}rÖr rr1r>) r*Z read_slaveZ write_slaveZslave_read_objZ read_connectrírÛrZ write_connectrîr)rJrôrérÌrërÚtest_bidirectional_ptyèsz    ÿ  ÿ   ÿ  ÿ ÿ  ÿ  ÿz*EventLoopTestsMixin.test_bidirectional_ptycsæt ¡\}}| d¡ˆj ˆj |d¡¡‰tˆddƒ}|durLˆ |j¡‡‡fdd„}t   ¡}ˆj |ƒ¡}ˆj  ¡t   ¡|}ˆ  |d¡ˆ  | ¡d¡ˆ tjˆj¡|durƈ |j¡ˆj |¡| ¡| ¡dS)NFrlÚovc“sZzHzˆj ˆj¡ˆIdHWntjy6d}Yn0d}Wˆj ¡n ˆj ¡0|S)NÚ cancelled)r'r r¾rÚCancelledErrorr‘)r·©r=r*rrÚmain;s z:EventLoopTestsMixin.test_prompt_cancellation..mainrŒr )rÑrÒrÓr'rnrÿÚgetattrr„ÚpendingrÚ monotonicr›Z assertLessrœÚresultr‰rr r¿rwr1)r*rËr×r rr®r°ÚelapsedrrrÚtest_prompt_cancellation3s&          z,EventLoopTestsMixin.test_prompt_cancellationcsh‡‡fdd„}ˆjj‰dˆj_|ˆj_‡fdd„}ˆj |ƒ¡ˆ ˆjjdˆjjˆjjjjdœ¡dS)Ncsˆjjd7_ˆƒdSrà)r'Ú_run_once_counterr©Z orig_run_oncer*rrÚ _run_onceWsz._run_oncerc“sZˆj}t d¡IdHt d¡IdHt d¡IdHt d¡IdHt d¡IdHdS)Nrõg-Cëâ6?gíµ ÷ư>g:Œ0âŽyE>g»½×Ùß|Û=)r'rr‚rgr0rrÚwait_s z7EventLoopTestsMixin.test_timeout_rounding..waité)Zclock_resolutionÚselector) r'rrr&ZassertLessEqualZ_clock_resolutionÚ _selectorrWr3)r*rrrrrÚtest_timeout_roundingVs   ÿÿz)EventLoopTestsMixin.test_timeout_roundingcCsx| ¡}dd„}t ¡\}}| |j¡| |j¡| ||¡| ||¡| ¡| | |¡¡| |  |¡¡dS)NcSsdSrrrrrrrÏrrizCEventLoopTestsMixin.test_remove_fds_after_closing..) r{rÑrÒrbr1rÕrÛr¿rÆrÜ©r*r'r™rËr×rrrÚtest_remove_fds_after_closingps     z1EventLoopTestsMixin.test_remove_fds_after_closingcCs¬| ¡}dd„}t ¡\}}| |j¡| |j¡| ¡| t¡| ||¡Wdƒn1sh0Y| t¡| ||¡Wdƒn1sž0YdS)NcSsdSrrrrrrrÏ~riz@EventLoopTestsMixin.test_add_fds_after_closing..) r{rÑrÒrbr1r‰rŠrÕrÛrrrrÚtest_add_fds_after_closing|s    * z.EventLoopTestsMixin.test_add_fds_after_closingcsP‡fdd„}|ˆjƒ}ˆ t¡ˆj |¡Wdƒn1sB0YdS)Nc“sˆj ¡dSr)r'r1rgr0rrÚ close_loop‰szEEventLoopTestsMixin.test_close_running_event_loop..close_loop)r'r‰rŠr&)r*r!rerr0rÚtest_close_running_event_loopˆs   z1EventLoopTestsMixin.test_close_running_event_loopcCsJ|j ¡dd„}dd„}|ƒ}| |j¡| t¡|j ¡Wdƒn1sV0Y| t¡&|j ¡}|j |¡Wdƒn1s–0Y| t¡|j |¡Wdƒn1sÌ0Y| t¡|j  |¡Wdƒn1s0Y| t¡|j  d|¡Wdƒn1s>0Y| t¡(|j  |j  ¡d|¡Wdƒn1s‚0Y| t¡|j  |¡Wdƒn1sº0Y| t¡ |j tj|¡Wdƒn1sö0Y| t¡*|j d|¡ ¡}t|ƒWdƒn1s<0YdS)NcÓsdSrrrrrrÚtest“sz,EventLoopTestsMixin.test_close..testcSsdS©NFrrrrrrÏ–riz0EventLoopTestsMixin.test_close..gð?g)r'r1rbr‰rŠr›r<r&r r¤ršÚcall_atrrnræréÚSIGTERMrµr2Únext)r*r#ÚfuncreZfutÚitrrrÚ test_closes2   (  * * , . 8 , 0 zEventLoopTestsMixin.test_close)T)TN)TN)NN)N)N)N)Yr3r4r5rzr€r‹rr“ržr¡r±r²r¸rÀrØrÞr_Ú skipUnlessr)réròrúrýr rr Zskip_unless_bind_unix_socketrrrr1ÚskipIfrr6r9r>rDr\rarfrr*rzr|rr„rÑr‰r‘r“r•rœrržr¢r¤r°r²r¶r¸r¹r¾rÀZ IPV6_ENABLEDrÄrÆrÏrÐrÑrÕrÖrrrçrñrörýrr Úrequires_mac_verrr rrrr r"r*rYrrrVrryïsò       +    ÿ !þ ÿ %    6   $              (0   ÿ ÿ ÿ ! ÿ % ÿ  ÿ  ' ÿ  F#  ryc@sžeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z e   ejdkd¡dd„ƒZdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#S)$ÚSubprocessTestsMixincCs,tjdkr| |t¡n| tj |¡dS©Nr)rrrÿrrœrér&©r*rqrrrÚcheck_terminated·s z%SubprocessTestsMixin.check_terminatedcCs,tjdkr| |t¡n| tj |¡dSr/)rrrÿrrœrérßr0rrrÚ check_killed¾s z!SubprocessTestsMixin.check_killedc Cs tj tj t¡d¡}|j t t |j¡t j |¡}|  t ¡Î|j |¡\}}| |t ¡|j |j¡| d|j¡| d¡}| d¡|j |jd ¡¡t ¡| ¡Wdƒn1sÆ0Y|j |j¡| |j¡| d|jd¡Wdƒn1s0YdS)Núecho.pyrBróPython The Winnerrl)rìrŠr¯ÚdirnameÚ__file__r'Úsubprocess_execr4r5rdrÚ executableÚ assertWarnsÚDeprecationWarningr&rÿr=rœr:Úget_pipe_transportrUrsrr}r,r1rnr2rqrJ©r*ÚprogrIÚtransprRÚstdinrrrÚtest_subprocess_execÅs$ þ     & z)SubprocessTestsMixin.test_subprocess_execc Csdtj tj t¡d¡}|j t t |j¡t j |¡}|  t ¡|j |¡\}}| |t ¡|j |j¡| d|j¡| d¡}| d¡|j |jd ¡¡|jd ¡| d|jd¡| d¡|j |jd ¡¡| d|jd¡t ¡| ¡Wdƒn1s0Y|j |j¡| |j¡Wdƒn1sV0YdS)Nr3rBrsPython rls The Winnerr4)rìrŠr¯r5r6r'r7r4r5rdrr8r9r:r&rÿr=rœr:r;rUrsrÚclearrJr}r,r1rnr2rqr<rrrÚtest_subprocess_interactiveÚs, þ     (z0SubprocessTestsMixin.test_subprocess_interactivecCsê| t¡Ì|j t t|j¡d¡}|j |¡\}}| |t¡|j |j ¡|  d¡  ¡|j |j ¡|  d|j¡| tdd„|j ¡Dƒƒ¡|  |jd d¡d¡|  |jdd ¡|  ¡Wdƒn1sÜ0YdS) Nz echo Pythonrcss|]}| ¡VqdSr)r>)rer=rrrÚ riz=SubprocessTestsMixin.test_subprocess_shell..rls sPythonrmri)r9r:r'Úsubprocess_shellr4r5rdr&rÿr=r;r1rnrœrqr„ÚallrpÚvaluesrJÚrstrip©r*rIr>rRrrrÚtest_subprocess_shellös  þ z*SubprocessTestsMixin.test_subprocess_shellcCsŽ|jjt t|j¡ddddd}| t¡ |j |¡\}}Wdƒn1sP0Y| |t¡|j |j ¡|  d|j ¡|  ¡dS)Núexit 7©r?ÚstdoutÚstderré) r'rDr4r5rdr9r:r&rÿrnrœrqr1rHrrrÚtest_subprocess_exitcodes þ . z-SubprocessTestsMixin.test_subprocess_exitcodecCsÄ|jjt t|j¡ddddd}| t¡ |j |¡\}}Wdƒn1sP0Y| |t¡|  |  d¡¡|  |  d¡¡|  |  d¡¡|j |j ¡|  d|j ¡|  | ¡¡dS)NrJrKrrlrmrN)r'rDr4r5rdr9r:r&rÿr­r;rnrœrqr1rHrrrÚ"test_subprocess_close_after_finishs þ . z7SubprocessTestsMixin.test_subprocess_close_after_finishcCs´tj tj t¡d¡}|j t t |j¡t j |¡}|  t ¡d|j |¡\}}| |t ¡|j |j¡| ¡|j |j¡| |j¡| ¡Wdƒn1s¦0YdS©Nr3)rìrŠr¯r5r6r'r7r4r5rdrr8r9r:r&rÿr=rírnr2rqr1©r*r=rIr>rRrrrÚtest_subprocess_kill!s þ   z)SubprocessTestsMixin.test_subprocess_killcCs´tj tj t¡d¡}|j t t |j¡t j |¡}|  t ¡d|j |¡\}}| |t ¡|j |j¡| ¡|j |j¡| |j¡| ¡Wdƒn1s¦0YdSrQ)rìrŠr¯r5r6r'r7r4r5rdrr8r9r:r&rÿr=Ú terminaternr1rqr1rRrrrÚtest_subprocess_terminate2s þ   z.SubprocessTestsMixin.test_subprocess_terminaterzDon't have SIGHUPc Csòt tjtj¡}zÌtj tj t¡d¡}|j  t   t |j¡t j|¡}| t¡n|j |¡\}}| |t ¡|j |j¡| tj¡|j |j¡| tj |j¡| ¡Wdƒn1sÂ0YWt tj|¡nt tj|¡0dSrQ)réÚSIGHUPÚSIG_DFLrìrŠr¯r5r6r'r7r4r5rdrr8r9r:r&rÿr=Ú send_signalrnrœrqr1)r*Z old_handlerr=rIr>rRrrrÚtest_subprocess_send_signalCs  þ   (z0SubprocessTestsMixin.test_subprocess_send_signalcCsòtj tj t¡d¡}|j t t |j¡t j |¡}|  t ¡¢|j |¡\}}| |t ¡|j |j¡| d¡}| d¡|j |j¡| ¡| d|jd¡| |jd d¡|jd¡| d|j¡Wdƒn1sä0YdS)Núecho2.pyrótestóOUT:testrlrmsERR:test)rìrŠr¯r5r6r'r7r4r5rdrr8r9r:r&rÿr=r;rUrnr1rœrJr„rrqr<rrrÚtest_subprocess_stderr\s  þ    z+SubprocessTestsMixin.test_subprocess_stderrcCstj tj t¡d¡}|jjt t |j¡t j |t j d}| t¡Â|j |¡\}}| |t ¡|j |j¡| d¡}| | d¡¡| | d¡¡| d¡|j |j¡| |jd d¡|jd¡| d|jd¡| ¡| d|j¡Wdƒn1s 0YdS) NrZ)rMrrlrmr[sOUT:testERR:testri)rìrŠr¯r5r6r'r7r4r5rdrr8Ú subprocessÚSTDOUTr9r:r&rÿr=r;rr­rUrnr„rJrrœr1rqr<rrrÚ)test_subprocess_stderr_redirect_to_stdoutrs(  þ    ÿz>SubprocessTestsMixin.test_subprocess_stderr_redirect_to_stdoutc CsŒtj tj t¡d¡}|j t t |j¡t j |¡}|  t ¡8|j |¡\}}| |t ¡|j |j¡| d¡}| d¡}| d¡|j |jd ¡¡| d|jd¡| ¡|j |jd¡| d¡|j |jd ¡¡t jdkr | d |jd¡n| d |jd¡t ¡| ¡Wdƒn1sD0Y|j |j¡| |j¡Wdƒn1s~0YdS) Nzecho3.pyrrlr[r\rrmrsERR:BrokenPipeErrors ERR:OSError)rìrŠr¯r5r6r'r7r4r5rdrr8r9r:r&rÿr=r;rUrsrrœrJr1rprr}r,rnr2rq)r*r=rIr>rRr?rLrrrÚ#test_subprocess_close_client_stream‹s2 þ       (z8SubprocessTestsMixin.test_subprocess_close_client_streamccs`|jjt t|j¡dddddd}|j |¡V\}}| |t¡|j |j¡| d|j ¡dS)NrJT)r?rLrMÚstart_new_sessionrN) r'rDr4r5rdr&rÿrnrœrq)r*rIr[rRrrrÚ"test_subprocess_wait_no_same_group­s ý z7SubprocessTestsMixin.test_subprocess_wait_no_same_groupcsćfdd„}ˆ t¡"ˆj |dd¡Wdƒn1s>0Yˆ t¡"ˆj |dd¡Wdƒn1sz0Yˆ t¡"ˆj |dd¡Wdƒn1s¶0YdS)Nc›s"ˆjjtjdfi|¤ŽIdHdS©NÚpwd)r'r7rÚSubprocessProtocol)ror0rrrI¹s þþzGSubprocessTestsMixin.test_subprocess_exec_invalid_args..connectT©Úuniversal_newlinesé©Úbufsize©Úshell©r‰rèr'r&©r*rIrr0rÚ!test_subprocess_exec_invalid_args¸s  0 0 z6SubprocessTestsMixin.test_subprocess_exec_invalid_argscsd ‡fdd„ }ˆ t¡$ˆj |ddgƒ¡Wdƒn1sB0Yˆ t¡"ˆj |dd¡Wdƒn1s~0Yˆ t¡"ˆj |dd¡Wdƒn1sº0Yˆ t¡"ˆj |d d ¡Wdƒn1sö0YdS) Nc›s*|sd}ˆjjtj|fi|¤ŽIdHdSrd)r'rDrrf)Úcmdror0rrrIÇsþþzHSubprocessTestsMixin.test_subprocess_shell_invalid_args..connectZlsz-lTrgrirjFrl)Nrnrorr0rÚ"test_subprocess_shell_invalid_argsÅs 2 0 0 z7SubprocessTestsMixin.test_subprocess_shell_invalid_argsN)r3r4r5r1r2r@rBrIrOrPrSrUr_r,rrrYr]r`rarcrprrrrrrr.µs"  "  r.c@seZdZdd„ZdS)ÚSelectEventLoopTestscCst ¡Sr)rÚSelectorEventLoopr0rrrr{Ýsú&SelectEventLoopTests.create_event_loopN©r3r4r5r{rrrrrsÚsrsc@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)ÚProactorEventLoopTestscCst ¡Sr)rZProactorEventLoopr0rrrr{äsz(ProactorEventLoopTests.create_event_loopcCst d¡‚dS©Nz(IocpEventLoop does not have add_reader()©r_r`r0rrrrØçsz+ProactorEventLoopTests.test_reader_callbackcCst d¡‚dSrxryr0rrrÚtest_reader_callback_cancelêsz2ProactorEventLoopTests.test_reader_callback_cancelcCst d¡‚dS©Nz(IocpEventLoop does not have add_writer()ryr0rrrrÞísz+ProactorEventLoopTests.test_writer_callbackcCst d¡‚dSr{ryr0rrrÚtest_writer_callback_cancelðsz2ProactorEventLoopTests.test_writer_callback_cancelcCst d¡‚dSrxryr0rrrrósz4ProactorEventLoopTests.test_remove_fds_after_closingN) r3r4r5r{rØrzrÞr|rrrrrrwàs rwcs(eZdZ‡fdd„Z‡fdd„Z‡ZS)ÚUnixEventLoopTestsMixincs,tƒ ¡t ¡}| |j¡t |¡dSr)rTrzrÚSafeChildWatcherÚ attach_loopr'Úset_child_watcher©r*ZwatcherrVrrrzùs  zUnixEventLoopTestsMixin.setUpcst d¡tƒ ¡dSr)rr€rTr€r0rVrrr€ÿs z UnixEventLoopTestsMixin.tearDown)r3r4r5rzr€rYrrrVrr}øs r}ÚKqueueSelectorcs\eZdZdd„Ze dd¡e ej   d¡d¡‡fdd„ƒƒZ e dd¡‡fd d „ƒZ ‡Z S) ÚKqueueEventLoopTestscCst t ¡¡Sr)rrtÚ selectorsr‚r0rrrr{ sÿz&KqueueEventLoopTests.create_event_loopré Zopenbsdztest hangs on OpenBSDcstƒ ¡dSr)rTrör0rVrrrösz)KqueueEventLoopTests.test_read_pty_outputcstƒ ¡dSr)rTrr0rVrrrsz#KqueueEventLoopTests.test_write_pty)r3r4r5r{r r-r_r,rrrrörrYrrrVrrƒs ÿ rƒÚ EpollSelectorc@seZdZdd„ZdS)ÚEPollEventLoopTestscCst t ¡¡Sr)rrtr„r†r0rrrr{"sz%EPollEventLoopTests.create_event_loopNrvrrrrr‡sr‡Ú PollSelectorc@seZdZdd„ZdS)ÚPollEventLoopTestscCst t ¡¡Sr)rrtr„rˆr0rrrr{*sz$PollEventLoopTests.create_event_loopNrvrrrrr‰&sr‰c@seZdZdd„ZdS)rscCst t ¡¡Sr)rrtr„ÚSelectSelectorr0rrrr{2sruNrvrrrrrs.scOsdSrr)r»rrrrÚnoop6sr‹csheZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z e   e e jdƒd¡dd„ƒZ‡ZS)Ú HandleTestscs"tƒ ¡t ¡|_d|jj_dSr¹)rTrzrrvr'Ú get_debugÚ return_valuer0rVrrrz<s  zHandleTests.setUpcCs`dd„}d}t |||j¡}| |j|¡| |j|¡| | ¡¡| ¡|  | ¡¡dS)NcWs|Srrrºrrrr™Bsz)HandleTests.test_handle..callbackr) rÚHandler'rÚ _callbackÚ_argsr¿r r¾r„)r*r™r»ÚhrrrÚ test_handleAszHandleTests.test_handlecCs\dd„}t ¡|_t ¡|j_t |d|j¡}| ¡|jj t  d¡tj ||j dœ¡dS)NcSs tƒ‚dSr)rèrrrrr™Osz:HandleTests.test_callback_with_exception..callbackrzException in callback.*)rNr-ÚhandleZsource_traceback) rrvr'r¦rrZ_runÚassert_called_withr}Z MockPatternÚANYÚ_source_traceback)r*r™r’rrrÚtest_callback_with_exceptionNs  üz(HandleTests.test_callback_with_exceptioncCs(t ¡}t dd„d|j¡}||d<dS)NcSsdSrrrrrrrÏariz1HandleTests.test_handle_weakref..rr’)ÚweakrefÚWeakValueDictionaryrrr')r*Zwdr’rrrÚtest_handle_weakref_szHandleTests.test_handle_weakrefcCs¢d|jj_t td|j¡}t t¡\}}| t |ƒd||f¡|  ¡| t |ƒd¡|  t ¡t  t¡}Wdƒn1s‚0Yt |d|j¡}| t |ƒd||f¡t tdd¡}t |d |j¡}d t |¡|f}| t |ƒ|¡tjtdd }t |d |j¡}d t |¡|f}| t |ƒ|¡tjdkržtj}t |¡}t |¡\}}t |d|j¡}d}d|}d|t |¡|f}| t |ƒ|¡dS)NFrkzzrzrlrm)rjz%^$)Úx)rmrjz'^$)rjéz*z%functools.partialmethod\(%s, , \)\(\)z^$)r'rrŽrrr‹r}Úget_function_sourcerœrðr¾r9r:Ú coroutiner4r5ÚreÚescapeZ assertRegexrr]rŒÚtest_handle_reprÚ partialmethod)r*r’ÚfilenameÚlinenor’ZregexÚmethodZcb_regexrrrr¢dsV  ÿÿ ÿ ( ÿÿ ÿ ÿ  ÿzHandleTests.test_handle_reprcCs¢d|jj_t}t ¡jd}t t d|j¡}t   t ¡\}}|  t |ƒd||||f¡| ¡|  t |ƒd||||f¡| ¡|  t |ƒd||||f¡dS)NTrlrkz-z7)r'rrŽr6rÚ _getframeÚf_linenorrr‹r}ržrœrðr¾©r*Zcreate_filenameZ create_linenor’r¤r¥rrrÚtest_handle_repr_debug–s0   ÿÿ ÿþ ÿþz"HandleTests.test_handle_repr_debugcs|t ¡ ¡}| d¡ˆ |¡‡fdd„}| t¡}||ƒ| t¡}||ƒ| dt¡}||ƒ| dt¡}||ƒdS)NTcsBt d¡jd}ˆ |jt¡ˆ |jddd…t|df¡dS)NrlrärjÚtest_handle_source_traceback)rr§r¨rÿr—Úlistrœr6)r’r¥r0rrÚcheck_source_tracebackµsþÿzHHandleTests.test_handle_source_traceback..check_source_tracebackr) rÚget_event_loop_policyr$Ú set_debugr%r r‹r¤rš)r*r'r­r’rr0rr«°s       z(HandleTests.test_handle_source_tracebackÚ CoroutinezNo collections.abc.CoroutinecCsÂtƒ}d|_| t |¡¡| t |¡d¡d|_| t |¡d¡d|_ | t |¡d¡d|_|_| t |¡d¡tƒ}d|_| t |¡d ¡tƒ}d|_d|_ | t |¡d¡dS) NZAAAzAAA()ZBBBzBBB()Tz BBB() runningz%() runningr)z CoroLike()) r)r3r„rZ iscoroutinerœrZ_format_coroutiner5Ú cr_runningÚcr_code)r*rerrrÚ+test_coroutine_like_object_debug_formattingÍs&  ÿz7HandleTests.test_coroutine_like_object_debug_formatting)r3r4r5rzr“r˜r›r¢rªr«r_r+r)Ú collectionsÚabcr³rYrrrVrrŒ:s  2ÿrŒcsLeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ‡Z S)Ú TimerTestscstƒ ¡t ¡|_dSr)rTrzrrvr'r0rVrrrzñs zTimerTests.setUpcCs8t ¡}t |dd„dt ¡¡}| t|ƒt|ƒ¡dS)NcSsdSr$rrrrrrÏ÷riz&TimerTests.test_hash..r)rrrÚ TimerHandlerrvrœÚhash©r*Úwhenr’rrrÚ test_hashõs ÿzTimerTests.test_hashcCs4t ¡}t |dd„dt ¡¡}| || ¡¡dS)NcSsdSr$rrrrrrÏýriz&TimerTests.test_when..r)rrrr·rrvrœrºr¹rrrÚ test_whenûs ÿzTimerTests.test_whencCsœdd„}d}t ¡}t |||t ¡¡}| |j|¡| |j|¡|  |  ¡¡|  ¡|  |  ¡¡|  |j¡|  |j¡| ttjd|||j¡dS)NcWs|Srrrºrrrr™ sz'TimerTests.test_timer..callback)rlrmrj)rrrr·rrvrrr‘r¿r r¾r„r­r‰ÚAssertionErrorr')r*r™r»rºr’rrrÚ test_timer s   þzTimerTests.test_timercCsVd|jj_t dtd|j¡}t t¡}| t |ƒd|¡|  ¡| t |ƒd¡dS)NFé{rz&z ) r'rrŽrr·r‹r}ržrœrðr¾)r*r’ÚsrcrrrÚtest_timer_repr s   ÿ ÿzTimerTests.test_timer_reprcCs€d|jj_t}t ¡jd}t dt d|j¡}t   t ¡\}}|  t |ƒd||||f¡| ¡|  t |ƒd||||f¡dS)NTrlr¿rz7zA)r'rrŽr6rr§r¨rr·r‹r}ržrœrðr¾r©rrrÚtest_timer_repr_debug% s    þÿ  þÿz TimerTests.test_timer_repr_debugcCs:dd„}t ¡}t ||d|j¡}t ||d|j¡}| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ¡| ||k¡t ||d|j¡}t |d|d|j¡}| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡| ||k¡t |d|j¡}|  t |  |¡¡|  t |  |¡¡|  t¡|dkWdƒn1sè0Y|  t¡|dkWdƒn1s0Y|  t¡|dkWdƒn1sP0Y|  t¡|dkWdƒn1s„0Y| |dk¡| |dk¡| |tk¡| |tk¡| |tk¡| |tk¡| |tk¡| |tk¡| |tk¡| |tk¡| |tk¡| |tk¡dS)NcWs|Srrrºrrrr™; sz2TimerTests.test_timer_comparison..callbackrg$@)rrrr·r'r¿r„r¾rrÚNotImplementedÚ__eq__Ú__ne__r‰rår r r )r*r™rºZh1Zh2Zh3rrrÚtest_timer_comparison: sf ( ( ( (z TimerTests.test_timer_comparison) r3r4r5rzr»r¼r¾rÁrÂrÆrYrrrVrr¶ïs r¶c@seZdZdd„Zdd„ZdS)ÚAbstractEventLoopTestscCs t ¡}t ¡}| t|j¡| t|jd¡| t|j¡| t|j ¡| t|j ¡| t|j ¡| t|j d¡| t|j dd¡| t|j||¡| t|jd¡| t|j¡| t|jd¡| t|j|¡| t|jd|¡| t|jd¡| t|jd|¡| t|jd¡| t|jd|¡| t|jd¡| t|jd¡| t|j|¡| t|j|¡| t|j|¡| t|j¡| t|j|¡dSrà)rrvrÚAbstractEventLoopr‰ÚNotImplementedErrorr›r&r‘r…r|r1rnršr%r rr¤Zset_default_executorrÕrÆrÛrÜrærçZset_exception_handlerZdefault_exception_handlerr¦rr¯)r*r=r'rrrÚtest_not_implemented{ sšÿÿÿÿÿÿÿ ÿ ÿÿÿÿÿ ÿÿ ÿÿ ÿÿÿÿÿÿÿÿz+AbstractEventLoopTests.test_not_implementedcs,‡fdd„}t ¡}| |ƒ¡| ¡dS)Nc“s(t ¡}t ¡}ˆ t¡"| ||¡IdHWdƒn1sB0Yˆ t¡"| dd¡IdHWdƒn1s~0Yˆ t¡ | d¡IdHWdƒn1s¸0Yˆ t¡ |  |¡IdHWdƒn1sò0Yˆ t¡ |  |¡IdHWdƒn1s.0Yˆ t¡ |  |¡IdHWdƒn1sj0Yˆ t¡"|  |d¡IdHWdƒn1s¨0Yˆ t¡"|  |d¡IdHWdƒn1sæ0Yˆ t¡"| |d¡IdHWdƒn1s$0Yˆ t¡"| ||¡IdHWdƒn1sb0Yˆ t¡ | |¡IdHWdƒn1sž0Yˆ t¡"| ||¡IdHWdƒn1sÜ0Yˆ t¡"| ||¡IdHWdƒn1s0Yˆ t¡&| |tjj¡IdHWdƒn1s\0Yˆ t¡&| |tjj¡IdHWdƒn1sž0Yˆ t¡$| |tj¡IdHWdƒn1sÞ0Yˆ t¡ | |¡IdHWdƒn1s0YdS)Nr·é)r·rËr)rrvrrÈr‰rÉrµrmrÌrrSrËrÿZsock_recv_intoZ sock_sendallZ sock_connectZ sock_acceptZ sock_sendfileÚsendfilerÙÚsentinelrârìrDr7)r=r'r0rrÚinner³ sH 0 0 . . 0 0 2 2 2 2 0 2 2 6 6 4 z@AbstractEventLoopTests.test_not_implemented_async..inner)rr$r&r1)r*rÎr'rr0rÚtest_not_implemented_async± s ' z1AbstractEventLoopTests.test_not_implemented_asyncN)r3r4r5rÊrÏrrrrrÇy s6rÇc@s^eZdZdd„Zdd„Zdd„Zdd„Ze d ¡d d „ƒZ d d „Z dd„Z dd„Z dd„Z dS)Ú PolicyTestscCsZt ¡}| t|j¡| t|jtƒ¡| t|j¡| t|j¡| t|j tƒ¡dSr) rÚAbstractEventLoopPolicyr‰rÉÚget_event_loopr%r¬r$Zget_child_watcherr€©r*ÚpolicyrrrÚtest_event_loop_policyá s ÿz"PolicyTests.test_event_loop_policycCsXt ¡}| |jj¡| ¡}| |tj¡| |jj|¡| || ¡¡|  ¡dSr) rÚDefaultEventLoopPolicyr­Ú_localZ_looprÒrÿrÈrr1©r*rÔr'rrrÚtest_get_event_loopê szPolicyTests.test_get_event_loopcCsZt ¡}tjj|d|jd"}| ¡}| |¡Wdƒn1sD0Y| ¡dS)Nr%)Úwraps) rrÖrr*r¬r%rÒr•r1)r*rÔZm_set_event_loopr'rrrÚ(test_get_event_loop_calls_set_event_loopõ sþ(z4PolicyTests.test_get_event_loop_calls_set_event_loopcCs$t ¡}| d¡| t|j¡dSr)rrÖr%r‰rŠrÒrÓrrrÚ"test_get_event_loop_after_set_none s z.PolicyTests.test_get_event_loop_after_set_nonez'asyncio.events.threading.current_threadcs,‡fdd„}tj|d}| ¡| ¡dS)Ncst ¡}ˆ t|j¡dSr)rrÖr‰rŠrÒ)rÔr0rrr= sz1PolicyTests.test_get_event_loop_thread..fr¨)rªr­r®r¯)r*Zm_current_threadr=Úthrr0rÚtest_get_event_loop_thread s  z&PolicyTests.test_get_event_loop_threadcCs*t ¡}| ¡}| |tj¡| ¡dSr)rrÖr$rÿrÈr1rØrrrÚtest_new_event_loop szPolicyTests.test_new_event_loopcCsht ¡}| ¡}| t|jtƒ¡| ¡}| |¡| || ¡¡|  || ¡¡|  ¡|  ¡dSr) rrÖrÒr‰r½r%r¬r$rÚ assertIsNotr1)r*rÔZold_loopr'rrrÚtest_set_event_loop s zPolicyTests.test_set_event_loopcCs*t ¡}| |tj¡| |t ¡¡dSr)rr®rÿrÑrrÓrrrÚtest_get_event_loop_policy) sz&PolicyTests.test_get_event_loop_policycCsL| ttjtƒ¡t ¡}t ¡}t |¡| |t ¡¡| ||¡dSr) r‰r½rrr¬r®rÖrrà)r*Ú old_policyrÔrrrÚtest_set_event_loop_policy. s ÿ z&PolicyTests.test_set_event_loop_policyN)r3r4r5rÕrÙrÛrÜrr*rÞrßrárârärrrrrÐß s    rÐcsReZdZdZdZdZdZ‡fdd„Z‡fdd„Ze j dkrBdd„Z d d „Z ‡Z S) ÚGetEventLoopTestsMixinNcsÌtj|_tj|_tj|_tj|_t |ƒj t_t |ƒj t_t |ƒj t_t |ƒj t_t |ƒj t_t |ƒj t_t |ƒj t_t |ƒj t_tƒ ¡t ¡|_t |j¡tjdkrÈt ¡}| |j¡t |¡dSr/)rÚ_get_running_loopÚ_get_running_loop_savedÚ_set_running_loopÚ_set_running_loop_savedÚget_running_loopÚget_running_loop_savedrÒÚget_event_loop_savedrÒÚ_get_running_loop_implÚ_set_running_loop_implÚget_running_loop_implÚget_event_loop_implrrTrzr$r'r%rrr~rr€rrVrrrzA s&             zGetEventLoopTestsMixin.setUpc sÒzvtjdkrt d¡tƒ ¡W|j ¡t d¡|j t _ |j t _ |jt _|jt _|j t_ |j t_ |jt_|jt_nV|j ¡t d¡|j t _ |j t _ |jt _|jt _|j t_ |j t_ |jt_|jt_0dSr/)rrrr€rTr€r'r1r%rçrrærérèrërêrìrÒr0rVrrr€[ s0      õ  zGetEventLoopTestsMixin.tearDownrcs.t ¡‡fdd„}ˆ ˆj |ƒ¡d¡dS)Nc“s*tj ¡}ˆj |t¡IdH}| ¡|Sr)Ú concurrentÚfuturesÚProcessPoolExecutorr'rµr(Úshutdown)Úpoolrr0rrrw s  ÿ zDGetEventLoopTestsMixin.test_get_event_loop_new_process..mainr")r Z*skip_if_broken_multiprocessing_synchronizerœr'r&)r*rrr0rÚtest_get_event_loop_new_processq s   þz6GetEventLoopTestsMixin.test_get_event_loop_new_processc s&Gdd„dtƒ‰G‡fdd„dtjƒ}t ¡}z„t |ƒ¡t ¡‰ˆ ˆ¡t ¡Wdƒn1sn0Yt d¡ˆ ˆ¡t ¡Wdƒn1sª0Yˆ  t d¡ ˆ  t  ¡d¡Wdƒn1sæ0Yˆ  t  ¡d¡‡‡fdd„}ˆ |ƒ¡t ˆ¡ˆ ˆ¡t ¡Wdƒn1sN0Yt d¡ˆ ˆ¡t ¡Wdƒn1sŒ0YWt |¡ˆdurÔˆ ¡nt |¡ˆdurÒˆ ¡0ˆ  t d¡ ˆ  t  ¡d¡Wdƒn1s0Yˆ  t  ¡d¡dS)Nc@s eZdZdS)zRGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop..TestErrorN)r3r4r5rrrrÚ TestErrorƒ sr÷cseZdZ‡fdd„ZdS)zOGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop..Policycsˆ‚dSrrr0©r÷rrrÒ‡ sz^GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop..Policy.get_event_loopN)r3r4r5rÒrrørrÚPolicy† srùz no runningc“s4ˆ t ¡ˆ¡ˆ t ¡ˆ¡ˆ t ¡ˆ¡dSr)rrrÒrêrær)r'r*rrr(™ szMGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop..func)rKrrÖr®rr$r‰rÒr%rcrŠrrêrær&r1)r*rùrãr(r)r÷r'r*rÚ(test_get_event_loop_returns_running_loop‚ s>  &  &.   (  *   þ   0z?GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop)r3r4r5rírîrïrðrzr€rrrörúrYrrrVrrå: s   råc@s$eZdZejZejZejZ ej Z dS)ÚTestPyGetEventLoopN) r3r4r5rZ_py__get_running_loopríZ_py__set_running_looprîZ_py_get_running_looprïZ_py_get_event_looprðrrrrrû³ srûc@s$eZdZejZejZejZ ej Z dS)ÚTestCGetEventLoopN) r3r4r5rZ_c__get_running_loopríZ_c__set_running_looprîZ_c_get_running_looprïZ_c_get_event_looprðrrrrrüÁ srüc@seZdZdd„ZdS)Ú TestServercsbt ¡}| |j¡t|ƒ‰| | ‡fdd„dd¡¡}| | ¡|¡| ¡| |  ¡¡dS)NcsˆSrrrrQrrrÏÏ riz*TestServer.test_get_loop..r€r) rr$rbr1rSr&rSrœÚget_loopÚ wait_closed)r*r'ryrrQrÚ test_get_loopË s zTestServer.test_get_loopN)r3r4r5rrrrrrýÉ srýc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestAbstractServercCs:| t¡t ¡ ¡Wdƒn1s,0YdSr)r‰rÉrÚAbstractServerr1r0rrrr*× s zTestAbstractServer.test_closecCsTt ¡}| |j¡| t¡"| t ¡  ¡¡Wdƒn1sF0YdSr) rr$rbr1r‰rÉr&rrrÿr?rrrÚtest_wait_closedÛ s  z#TestAbstractServer.test_wait_closedcCs:| t¡t ¡ ¡Wdƒn1s,0YdSr)r‰rÉrrrþr0rrrrâ s z TestAbstractServer.test_get_loopN)r3r4r5r*rrrrrrrÕ srÚ__main__)LÚ__doc__Úcollections.abcr´Úconcurrent.futuresrñr4rãrìrr rérÑrÚ ImportErrorr^rrªrr@r_rr™r rrrrrZtest.test_asynciorr}r#r Z test.supportr r r r rr r(r)rr6rSZDatagramProtocolrZraZ BaseProtocolrcrfrdryr.ZTestCasersrwr„r}r)rƒr‡r‰r‹rŒr¶rÇrÐrårûZ_asynciorürýrr3rrrrrÚsÐ              " )Q%  ÿ þ  þ  þ  þ þ6 f[y