a  ze9@sndZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZe jZejd kZd d Zd dZddZGdddejZGdddejZ Gddde j!Z"Gddde j#Z$GdddejZ%Gddde jZ&GdddejZ'Gdd d ejZ(e)d!krje *dS)"zTests for base_events.pyN)mock) base_events) constants)utils)support)assert_python_ok) socket_helper)cCstddSN)asyncioZset_event_loop_policyr r V/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_asyncio/test_base_events.pytearDownModulesrcCs`tjtd}dD],}tt|r2t||tt|qt||qt|_t|j_ d|j _ |S)N)spec) AF_INETAF_INET6 AF_UNSPEC IPPROTO_TCP IPPROTO_UDP SOCK_STREAM SOCK_DGRAM SOL_SOCKET SO_REUSEADDR inet_ptonF) rZ MagicMocksockethasattrsetattrgetattrdelattr test_utilsZmock_nonblocking_socket return_value getaddrinfo _is_coroutine)m_socketnamer r rmock_socket_modules     r&cCstjdtd|S)Nzasyncio.base_events.socket)Z new_callable)rpatchr&)fr r r patch_socket0s r)c@s(eZdZddZddZeddZdS)BaseEventTestsc Cstj}tj}tj}tj}tj}tj}tj}||||ddft dd|||||||ddft dd|||||||ddft dd|||||||ddft dd|||||||ddft dd||d||||ddft dd||d| t dd|ddt j r| t dd|||||||ddft dd|||||||ddft dd|||| t dd|||| t d d|||dS) N1.2.3.4r-r.s1.2.3.4r)::3r.rrr/z::3%lo0)rrrrrrrr assertEqualr _ipaddr_info assertIsNoner IPV6_ENABLED)selfZUNSPECINETZINET6STREAMZDGRAMTCPZUDPr r rtest_ipaddr_info7sh        zBaseEventTests.test_ipaddr_infoc Cstj}tj}tj}||||ddftdd|||||||ddftdd|||||||ddftdd|||||||ddftdd|||||||ddftdd|||dS)Nr+r-rr-r,11)rrrrr0rr1)r4r5r6r7r r rtest_port_parameter_typesss.     z(BaseEventTests.test_port_parameter_typesc Cs&|`|tddtjtjtjdS)Nr-r.)rr2rr1rrrrr4r$r r rtest_ipaddr_info_no_inet_ptons  z,BaseEventTests.test_ipaddr_info_no_inet_ptonN)__name__ __module__ __qualname__r8r=r)r?r r r rr*5s<r*csleZdZfddZddZddZddZd 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=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-Z.S)WBaseEventLoopTestscs<tt|_t|j_d|jjj_ | |jdSNr ) supersetUpr BaseEventLooplooprMock _selectorselectr!set_event_loopr4 __class__r rrFs     zBaseEventLoopTests.setUpc Cst}|t|jj|||t|jj|||||t|jj|||t|jjg|t|jj |t|jj |||t|jj |||j |||||||}|t| dWdn1s0YdSr )rrI assertRaisesNotImplementedErrorrHZ_make_socket_transport_make_ssl_transportZ_make_datagram_transport_process_events_write_to_selfZ_make_read_pipe_transportZ_make_write_pipe_transportZ_make_subprocess_transportsend)r4mgenr r rtest_not_implementeds<      z'BaseEventLoopTests.test_not_implementedcCsn||j|j||j|j|j|j}|t|jj|t|jj |dSr ) assertFalserHZ is_closedclose assertTrue create_futurerP RuntimeError run_foreverrun_until_complete)r4r(r r r test_closes    zBaseEventLoopTests.test_closecCsDtddd|jd}|j|||jj|||jjdS)NcSsdSNFr r r r rr:z>BaseEventLoopTests.test__add_callback_handle..r )r HandlerH _add_callbackrY _scheduledassertIn_readyr4hr r rtest__add_callback_handles z,BaseEventLoopTests.test__add_callback_handlecCsJtddd|jd}||j|||jj||jjdS)NcSsdSrar r r r rrbr:zHBaseEventLoopTests.test__add_callback_cancelled_handle..r )r rcrHcancelrdrYrergrhr r r#test__add_callback_cancelled_handles  z6BaseEventLoopTests.test__add_callback_cancelled_handlecCsRGdddtjj}t|j_t|j_|}|j|| ||jj dS)Nc@seZdZddZdS)zCBaseEventLoopTests.test_set_default_executor..DummyExecutorc_s tddS)Nz#cannot submit into a dummy executor)rQ)r4fnargskwargsr r rsubmitszJBaseEventLoopTests.test_set_default_executor..DummyExecutor.submitN)r@rArBrpr r r r DummyExecutorsrq) concurrentfuturesThreadPoolExecutorrrIrHrSrTset_default_executorassertIs_default_executor)r4rqexecutorr r rtest_set_default_executors    z,BaseEventLoopTests.test_set_default_executorcCsJt}|t|j|Wdn1s40Yd|j_dSr )rrI assertWarnsDeprecationWarningrHrurw)r4rxr r r.test_set_default_executor_deprecation_warningss *zABaseEventLoopTests.test_set_default_executor_deprecation_warningscCsDdd}|j|}||j|||tj|||jjdS)NcSsdSr r r r r rcbsz-BaseEventLoopTests.test_call_soon..cb) rH call_soonr0 _callbackassertIsInstancer rcrfrgr4r}rir r rtest_call_soons  z!BaseEventLoopTests.test_call_sooncCsH|jd|td|jdWdn1s:0YdS)NTza callable objectr.)rH set_debugassertRaisesRegex TypeErrorr~rMr r rtest_call_soon_non_callables z.BaseEventLoopTests.test_call_soon_non_callablecCsHdd}|jd|}||tj|||jj|||jjdS)NcSsdSr r r r r rr}sz.BaseEventLoopTests.test_call_later..cb$@) rH call_laterrr TimerHandlerfreZ assertNotInrgrr r rtest_call_laters z"BaseEventLoopTests.test_call_latercs\gfdd}t|j_|jd|d|jd|dt|j|ddgdS)Ncs|dSr )append)argZcallsr rr}sz>BaseEventLoopTests.test_call_later_negative_delays..cbab)rrIrHrSrr run_brieflyr0)r4r}r rrtest_call_later_negative_delayss   z2BaseEventLoopTests.test_call_later_negative_delayscs~fdd}tj_d}j|}j||j}jj|}||d||d|dS)NcsjdSr rHstopr rMr rr}sz4BaseEventLoopTests.test_time_and_call_at..cb皙?g?g?) rrIrHrStimecall_atr^ZassertGreaterEqualassertLessEqual)r4r}delayZwhent0Zdtr rMrtest_time_and_call_ats    z(BaseEventLoopTests.test_time_and_call_atcCsdd}|||rd}|t|||Wdn1sF0Y|t||d|Wdn1s~0Y|t|$||d|Wdq1s0Yn*|||d|||d|dS)NcSsdSr r r r r rr}"sz+BaseEventLoopTests.check_thread..cbzMNon-thread-safe operation invoked on an event loop other than the current one<)rrr]r~rrr)r4rHdebugr}msgr r r check_thread!s (*4  zBaseEventLoopTests.check_threadcsnfdddfdd }tj_tj_|jd|jd|jddd|jddddS) Nc s|z`|rZt}z,t|||Wtd|qftd|0n ||Wn2ty}z||j |WYd}~nd}~00||j ddSr ) waitrrGr rLrrZ Exceptioncall_soon_threadsafe set_exception set_result)rHeventr create_loopfutZloop2excrMr rcheck_in_thread5s    $z=BaseEventLoopTests.test_check_thread..check_in_threadFcsVt}|}||j|||||f}tj|d}||||dS)N)targetrn) threadingEventr\r~setThreadstartr_join)rHrrrrrnthread)rr r test_threadIs  z9BaseEventLoopTests.test_check_thread..test_threadT)r)F)rrIrHrSrT)r4rr )rr4rtest_check_thread4s     z$BaseEventLoopTests.test_check_threadcCsttdddd|jd}ttdddd|jd}|t|j_|jj ||jj ||j |jj j jdd}|d|kod kn|||g|jj ||jjjdS) Ng@cSsdSNTr r r r rrbdr:z3BaseEventLoopTests.test__run_once..r rcSsdSrr r r r rrbfr:rg#@g%@)r rr monotonicrHrkrrIrSrer _run_oncerJrK call_argsr[r0called)r4Zh1Zh2tr r rtest__run_oncecs   z!BaseEventLoopTests.test__run_oncecCs<|jd||j|jd||jdS)NTF)rHrr[Z get_debugrYrMr r rtest_set_debugus  z!BaseEventLoopTests.test_set_debugcs~ddfdd}ttd||jf|jd}t|j_|jj ||j | | gt |jjdS)NFcsd|dddS)NTcSsdSrr r r r rrbr:zOBaseEventLoopTests.test__run_once_schedule_handle..cb..)r~rHhandleZ processedr rr}sz=BaseEventLoopTests.test__run_once_schedule_handle..cbr.)r rrrrHrrIrSrerrr[r0listrgrr rrtest__run_once_schedule_handle{s   z1BaseEventLoopTests.test__run_once_schedule_handlecCst|j_|dtjko$dkndd}d}|jd|d}tdD]}|jd|}| qR|d7}tdD]}|jd |}| q~| ||tj | |jj ||j|d8}| |jj || t|jj||tttj tjd}ttj |d}||7}t|D]}|jd|q0||7}t|D]}|jd|}| qV| t|jj|||j| t|jj||td d |jjDdS) Nrg?cSsdSr r r r r rr}szEBaseEventLoopTests.test__run_once_cancelled_event_cleanup..cbr. idcSsg|] }|j qSr )Z _cancelled).0xr r r r:zMBaseEventLoopTests.test__run_once_cancelled_event_cleanup..)rrIrHrSr[rZ%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONrrangerkrZ_MIN_SCHEDULED_TIMER_HANDLESr0Z_timer_cancelled_countrlenreintmathceilmaxall)r4r}Znot_cancelled_countZcancelled_countrriZadd_cancel_countZadd_not_cancel_countr r r&test__run_once_cancelled_event_cleanupsd           z9BaseEventLoopTests.test__run_once_cancelled_event_cleanupcCs|t|jjddS)NZblah)rPrrHr_rMr r r"test_run_until_complete_type_errorsz5BaseEventLoopTests.test_run_until_complete_type_errorcCs2|j}|}||j|t|j|dSr )rHr\Z new_test_loop addCleanuprZrP ValueErrorr_)r4taskZ other_loopr r rtest_run_until_complete_loops   z/BaseEventLoopTests.test_run_until_complete_loopcsGdddtdd}fdd}t|j_|j|| |j|dWdn1sl0Y|j|ddS) Nc@s eZdZdS)z]BaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop..ShowStopperNr@rArBr r r r ShowStoppersrcst|IdHdSr r sleep)rr r rfooszUBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop..foocsdSr r r rr rthrowszWBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop..throwrg?) SystemExitrrIrHrSr~rPr_)r4rrr rr5test_run_until_complete_loop_orphan_future_close_loops    .zHBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loopcCstjddg}|t|jj|jjtj|t|jj|jjtj||t|jj|jjtjtjd|jt|jj|jjtjg|Rddi|jt|jj|jjtjg|Rddi|jt|jj|jjtjg|RddidS) N-cpass{universal_newlinesTshellbufsize) sys executablerPrrHr_Zsubprocess_execr SubprocessProtocol)r4rnr r r!test_subprocess_exec_invalid_argssJ        z4BaseEventLoopTests.test_subprocess_exec_invalid_argsc Cs|t|jj|jjtjd|t|jj|jjtjtjddg|jt|jj|jjtjddd|jt|jj|jjtjddd|jt|jj|jjtjddd dS) Nrrrzexit 0T)r)rr)r) rPrrHr_Zsubprocess_shellr rrrrMr r r"test_subprocess_shell_invalid_argss(     z5BaseEventLoopTests.test_subprocess_shell_invalid_argscstj_dd}td`}j}j|||fddj|j j t dt ttfdWdn1s0Ytdb}j}jd|||fd dj|j j t dt ttfdWdn1s0YdS) NcSs|ddddS)NTr.r)rrr r r zero_error,s zHBaseEventLoopTests.test_default_exc_handler_callback..zero_errorasyncio.base_events.loggercs jSr rrrMr rrb4r:zFBaseEventLoopTests.test_default_exc_handler_callback..Exception in callback.*zeroexc_info{Gz?cs jSr rrrMr rrb>r:)rrIrHrSr'r\r~add_done_callbackr^errorassert_called_withr MockPatternZeroDivisionErrorMOCK_ANYr)r4rlogrr rMr!test_default_exc_handler_callback)s(    $   z4BaseEventLoopTests.test_default_exc_handler_callbackcstj_dd}td}tj|jd}|fddjd}t t r||j j tdtttfdn|j j td d dWdn1s0YdS) NcstdIdHdddS)Nrr.rrr r r rzero_error_coroGszIBaseEventLoopTests.test_default_exc_handler_coro..zero_error_cororrcs jSr rrnrMr rrbNr:zBBaseEventLoopTests.test_default_exc_handler_coro..z.*exception was never retrievedrz(.*exception was never retrieved.*ZeroDivF)rrIrHrSr'r ensure_futurerr^r gc_collectPY34rrr rrr)r4rrrr rMrtest_default_exc_handler_coroDs&   z0BaseEventLoopTests.test_default_exc_handler_corocCs<|td|jdWdn1s.0YdS)NzA callable object or Nonespam)rrrHset_exception_handlerrMr r rtest_set_exc_handler_invalid_sz/BaseEventLoopTests.test_set_exc_handler_invalidcsddfdd}jdtj_jt}j|j||}| jt t d||j d|jdtd2}||jj t d tt t fd Wdn1s0Y|jrJdS) NcSs dddSNr.rr r r r rrdszBBaseEventLoopTests.test_set_exc_handler_custom..zero_errorcsj}j|Sr rHr~r)rr4rr rrun_loopgs  z@BaseEventLoopTests.test_set_exc_handler_custom..run_loopTz!Exception in callback.*zero_error) exceptionmessagerZsource_tracebackrrr)rHrrrIrSr2Zget_exception_handlerrrvrrr rZ_source_traceback reset_mockr'rrr)r4rZ mock_handlerrrr rrtest_set_exc_handler_customcs8     $z.BaseEventLoopTests.test_set_exc_handler_customcs|fdd}dd}tj_j|td2}||jjt dt t t fdWdn1sn0YdS)Ncs"dd}j|jdS)NcSs dddSrr r r r rrszTBaseEventLoopTests.test_set_exc_handler_broken..run_loop..zero_errorrrrMr rrs z@BaseEventLoopTests.test_set_exc_handler_broken..run_loopcSs tddSNr)AttributeErrorrHcontextr r rhandlersz?BaseEventLoopTests.test_set_exc_handler_broken..handlerrz$Unhandled error in exception handlerr) rrIrHrSrr'rrr rr r)r4rrrr rMrtest_set_exc_handler_brokens    z.BaseEventLoopTests.test_set_exc_handler_brokencsdGfdddtj}||jtfdd}td&}||jj dddWdn1sx0Yd d }d |tdP}||jj t d dd| d |td d tWdn1s0YdS)Ncs(eZdZeZeZfddZdS)z@BaseEventLoopTests.test_default_exc_handler_broken..Loopcs|tddSr r)r4r_contextr rdefault_exception_handlerszZBaseEventLoopTests.test_default_exc_handler_broken..Loop.default_exception_handlerN)r@rArBrrIrJrSrr rr rLoopsrcsdd}|dS)NcSs dddSrr r r r rrszXBaseEventLoopTests.test_default_exc_handler_broken..run_loop..zero_error)r~rr rr rrs zDBaseEventLoopTests.test_default_exc_handler_broken..run_looprz&Exception in default exception handlerTrcSs tddS)NZhamrr r r rcustom_handlerszJBaseEventLoopTests.test_default_exc_handler_broken..custom_handlerz9Exception in default exception.*while handling.*in customrr)rrGrrZr rLrr'rrrr rrfrvtyper)r4rrrrr )rrHrtest_default_exc_handler_brokens2     $   z2BaseEventLoopTests.test_default_exc_handler_brokencCsL|td|jdWdn1s.0Y||jdS)Nz'task factory must be a callable or Noner.)rrrHset_task_factoryr2get_task_factoryrMr r rtest_set_task_factory_invalids *z0BaseEventLoopTests.test_set_task_factory_invalidcst|j_Gdddtjdd}fdd}||j|j|| |j||j |}| t ||j ||jd||j|j |}| t |tj|t ||j |dS)Nc@s eZdZdS)z8BaseEventLoopTests.test_set_task_factory..MyTaskNrr r r rMyTasksrcsdSr r r r r rcorosz6BaseEventLoopTests.test_set_task_factory..corocs ||dSNrr rHrrr rrbr:z:BaseEventLoopTests.test_set_task_factory..)rrIrHrSr Taskr2rrrv create_taskr[ isinstancer_rY)r4rfactoryrr r rtest_set_task_factorys      z(BaseEventLoopTests.test_set_task_factorycCsdd}tdd|\}}}||dtd|ddd\}}}||dtd|ddd\}}}||d tdd|dd \}}}||dtdd d d|\}}}||d dS) N )zimport asynciozloop = asyncio.get_event_loop()zprint(loop.get_debug())z-ErsFalser+)PYTHONASYNCIODEBUGZ PYTHONDEVMODEr;sTrue)r'z-Xdev)rrr0rstrip)r4codestsstdoutstderrr r rtest_env_var_debugs*     z%BaseEventLoopTests.test_env_var_debugcstGdddtjdd}Gfdddtj}|||}tj|d}||d|_|dS) Nc@s eZdZdS)z3BaseEventLoopTests.test_create_task..MyTaskNrr r r rrsrcsdSr r r r r rtestsz1BaseEventLoopTests.test_create_task..testcseZdZfddZdS)z6BaseEventLoopTests.test_create_task..EventLoopcs |dSrr r4rrrHr rr"szBBaseEventLoopTests.test_create_task..EventLoop.create_taskN)r@rArBr"r r1r r EventLoopsr2rF) r r!rrGrLrrZ_log_destroy_pendingrZ)r4r/r2rrr r1rtest_create_task s  z#BaseEventLoopTests.test_create_taskc Cs`dd}t}|j|dd}z&||dW|||n|||0dS)NcsdSr r r r r rr/$szLBaseEventLoopTests.test_create_named_task_with_default_factory..test test_taskr%)r new_event_loopr"r0get_namer_rZ)r4r/rHrr r r+test_create_named_task_with_default_factory#s  z>BaseEventLoopTests.test_create_named_task_with_default_factoryc Csrdd}dd}t}|||j|dd}z&||dW|||n|||0dS)NcSstj||dSr)r r!rr r r task_factory0szSBaseEventLoopTests.test_create_named_task_with_custom_factory..task_factorycsdSr r r r r rr/3szKBaseEventLoopTests.test_create_named_task_with_custom_factory..testr4r5)r r6rr"r0r7r_rZ)r4r9r/rHrr r r*test_create_named_task_with_custom_factory/s   z=BaseEventLoopTests.test_create_named_task_with_custom_factorycCsldd}t|j_t|j_z|j|WntyDYn0|jt | |jjj dS)NcstdSr KeyboardInterruptr r r rraise_keyboard_interruptCszXBaseEventLoopTests.test_run_forever_keyboard_interrupt..raise_keyboard_interrupt) rrIrHrSZcall_exception_handlerr_r<rZrrrYrr4r=r r r#test_run_forever_keyboard_interrupt?s    z6BaseEventLoopTests.test_run_forever_keyboard_interruptcsdd}tj_zj|Wnty8Yn0fddd_zjjWntyzYn0 jdS)NcstdSr r;r r r rr=UszZBaseEventLoopTests.test_run_until_complete_baseexception..raise_keyboard_interruptcsjd_dSr)rHrrr funcr4r rrA_s zFBaseEventLoopTests.test_run_until_complete_baseexception..funcF) rrIrHrSr_r<rr~r^r[r>r r@r%test_run_until_complete_baseexceptionRs    z8BaseEventLoopTests.test_run_until_complete_baseexceptionc stddfdd}fddfdd|j_fjjj_tdd D]X}d |6jjj j  dWdq^1s0Yq^dS) Nrcs|vrjdSr rHr~)Z event_list)do_eventdoerevent_sentinelr4r r proc_eventsqszZBaseEventLoopTests.test_single_selecter_event_callback_after_stopping..proc_eventscsd7jdSNr.rCr ) callcountclear_selectorr4r rrDvszWBaseEventLoopTests.test_single_selecter_event_callback_after_stopping..do_eventcsdjjj_dSrD)rkrHrJrKr!r )rEr4r rrJ{sz]BaseEventLoopTests.test_single_selecter_event_callback_after_stopping..clear_selectorr.r z Loop %d/2) objectrHrSrJrKr!rZsubTestr~rr^r0)r4rGir )rIrJrDrErFr4r2test_single_selecter_event_callback_after_stoppingjs zEBaseEventLoopTests.test_single_selecter_event_callback_after_stoppingcsDdfdd}t|j_|j|t|j|ddS)Nrcs d7dSrHr r countr rcallbacksz2BaseEventLoopTests.test_run_once..callbackr.)rrIrHrSr~r Zrun_oncer0)r4rPr rNr test_run_onces     z BaseEventLoopTests.test_run_oncecCs4t|j_|j|j|jjjddSNr) rrIrHrSrr^rJrKZassert_called_once_withrMr r rtest_run_forever_pre_stoppeds   z/BaseEventLoopTests.test_run_forever_pre_stoppedcsFddddfdd}|}|fddtS)NF)startedstopped finalizedc s4dd<zdD] }|VqWdd<n dd<0dS)NTrT)ZZEROZONEZTWOTHREEZFOURrVr item)statusr ragens  z;BaseEventLoopTests.leave_unfinalized_asyncgen..agencsLzIdH}Wnty&YdS0|dkr.iter_one) __aiter__r r")r4r[Zagr r^rleave_unfinalized_asyncgens  z-BaseEventLoopTests.leave_unfinalized_asyncgencCst|j_t|j_t|j|}|dsHt |jq2| |d| |d| |dt t |j| |dWdn1s0YdS)NrUrTrV)rrIrHrSrTr disable_gcr_rar rr[rYrr4rZr r r test_asyncgen_finalization_by_gcs    z3BaseEventLoopTests.test_asyncgen_finalization_by_gccCst|j_t|j_|jdt|j| }|dsTt |jq>| |d| |d| |d|j|jdtjt |j| |dWdn1s0YdS)NTrUrTrV)rrIrHrSrTrrrbr_rar rr[rYrun_in_executorrrcr r r0test_asyncgen_finalization_by_gc_in_other_threads     zCBaseEventLoopTests.test_asyncgen_finalization_by_gc_in_other_thread)/r@rArBrFrXr`rjrlryr|rrrrrrrrrrrrrrrrrrrr rrrr%r.r3r8r:r?rBrMrQrSrardrf __classcell__r r rNrrCsV      /L$0 "rCc@s:eZdZdZd ddZddZddZd d Zd d ZdS)MyProtoNFcCs"d|_d|_|rt|_dSNINITIALr)statenbytesr Zget_running_loopr\done)r4r\r r r__init__szMyProto.__init__cCs.||_|jdksJ|jd|_|ddS)Nrj CONNECTEDs%GET / HTTP/1.0 Host: example.com ) transportrkwriter4rpr r rconnection_madeszMyProto.connection_madecCs*|jdksJ|j|jt|7_dS)Nrorkrlrr4datar r r data_receivedszMyProto.data_receivedcCs|jdksJ|jd|_dS)NroEOFrkrMr r r eof_receivedszMyProto.eof_receivedcCs0|jdvsJ|jd|_|jr,|jddS)N)rorxCLOSEDrkrmrr4rr r rconnection_lostszMyProto.connection_lost)F) r@rArBrmrnrsrwrzr~r r r rrhs  rhc@s:eZdZdZd ddZddZddZd d Zd d ZdS)MyDatagramProtoNFcCsd|_d|_|r||_dSri)rkrlr\rm)r4r\rHr r rrnszMyDatagramProto.__init__cCs$||_|jdksJ|jd|_dS)Nrj INITIALIZED)rprkrrr r rrs szMyDatagramProto.connection_madecCs*|jdksJ|j|jt|7_dSNrrt)r4rvaddrr r rdatagram_receivedsz!MyDatagramProto.datagram_receivedcCs|jdksJ|jdSrryr}r r rerror_receivedszMyDatagramProto.error_receivedcCs0|jdksJ|jd|_|jr,|jddS)Nrr{r|r}r r rr~szMyDatagramProto.connection_lost)FN) r@rArBrmrnrsrrr~r r r rrs  rcseZdZfddZedddZeddZedd Z d d Z d d Z ddZ ddZ eeeddddZeejdddZddZddZddZdd Zd!d"Zed#d$Zd%d&Zeejdeej d'd(ed)d*Z!ed+d,Z"ed-d.Z#ed/d0Z$d1d2Z%ed3d4Z&d5d6Z'd7d8Z(d9d:Z)d;d<Z*d=d>Z+d?d@Z,dAdBZ-dCdDZ.edEdFZ/edGdHZ0edIdJZ1edKdLZ2dMdNZ3dOdPZ4dQdRZ5edSdTZ6eejdUdVdWZ7edXdYZ8dZd[Z9ed\d]Z:d^d_Z;eeed`dadbdcZdfdgZ?dhdiZ@djdkZAdldmZBedndoZCedpdqZDdrdsZEedtdudvZFdwdxZGedtdydzZHZIS){BaseEventLoopWithSelectorTestscs$tt|_||jdSr )rErFr ZSelectorEventLooprHrLrMrNr rrF s  z$BaseEventLoopWithSelectorTests.setUpzsocket.getnameinfocCs.dd|_|j|jd}||ddS)NcWsdS)N*r rr r rrb'r:zABaseEventLoopWithSelectorTests.test_getnameinfo..)abcrr) side_effectrHr_ getnameinfor0)r4Zm_gairr r rtest_getnameinfo%s z/BaseEventLoopWithSelectorTests.test_getnameinfocsGdddtj}ddfdd}ddd gfd d }||_|j_j|d d }t}j|Wdn1s0Y t |j ddS)Nc@s eZdZdS)zVBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors..MyProtoNrr r r rrh.srhcsddgSNrr.r+)z 107.6.106.82Pr rnkwr r rr"1szZBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors..getaddrinfocsj|i|Sr rHr"rnkwdsr"r4r rgetaddrinfo_task5sz_BaseEventLoopWithSelectorTests.test_create_connection_multiple_errors..getaddrinfo_taskrZerr1Zerr2csd7tdSrH)OSErrorr)errorsidxr r_socket;szVBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.._socket example.comrzMultiple exceptions: err1, err2) r ProtocolrrHr"create_connectionrPrr_r0strr)r4r$rhrrrcmr )rr"rr4r&test_create_connection_multiple_errors+s *zEBaseEventLoopWithSelectorTests.test_create_connection_multiple_errorsc st}||j_fdd}|j_tjjjdtj dfj t dd} tj j |Wdn1sz0Y|jjWdn1s0YdS)Ncs,j}tjtjdddf}||g|S)Nrr+) 127.0.0.1r)rHr\rrrr)rnrrrrMr rr"Ps    zRBaseEventLoopWithSelectorTests.test_create_connection_timeout..getaddrinfo sock_connect)rrr)rrIrr!rHr"r'rKr TimeoutErrorrrhrPr_r[rZr)r4r$sockr"rr rMrtest_create_connection_timeoutJs  *z=BaseEventLoopWithSelectorTests.test_create_connection_timeoutcCs,|jjtddtd}|t|jj|dS)Nrrr)rHrrhrKrPrr_r0r r r%test_create_connection_host_port_sock_s zDBaseEventLoopWithSelectorTests.test_create_connection_host_port_sockc Csttjtj}|X|jjt|d}|td|j|Wdn1sT0YWdn1sr0YdSNrzA Stream Socket was expected) rrrrHrrhrrr_r4rrr r r!test_create_connection_wrong_sockdsz@BaseEventLoopWithSelectorTests.test_create_connection_wrong_sockc Csttjtj}|X|jjt|d}|td|j|Wdn1sT0YWdn1sr0YdSr) rrrrH create_serverrhrrr_rr r rtest_create_server_wrong_socklsz.r) rrrrrHrr_rZ wait_closed)r4rrsrvr r r!test_create_server_stream_bittype|s z@BaseEventLoopWithSelectorTests.test_create_server_stream_bittypezno IPv6 supportc slfdd}zj|WnHtyf}z0ttdrP|jtjkrPdnWYd}~n d}~00dS)Ncst.tjddddjdIdH}Wdn1s>0Yz,t|jdW|| IdHn|| IdH0dS)NcSsdSr r r r r rrbr:zVBaseEventLoopWithSelectorTests.test_create_server_ipv6..main..::1rr) rzr{r Z start_serverrHZ assertGreaterrsocketsrZr)rrMr rmains *zDBaseEventLoopWithSelectorTests.test_create_server_ipv6..main EADDRNOTAVAILzfailed to bind to ::1)rHr_rrerrnorZskipTest)r4rexr rMrtest_create_server_ipv6s    z6BaseEventLoopWithSelectorTests.test_create_server_ipv6c Cs|ttj}|X|jjt|d}|td|j|Wdn1sP0YWdn1sn0YdS)NrzA UDP Socket was expected)rrrHcreate_datagram_endpointrhrrr_rr r r(test_create_datagram_endpoint_wrong_socks zGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_wrong_sockcCs"|jt}|t|jj|dSr rHrrhrPrr_r0r r r(test_create_connection_no_host_port_socks zGBaseEventLoopWithSelectorTests.test_create_connection_no_host_port_sockcsDddfdd}|j_jtdd}tjj|dS)NcsgSr r rr r rr"szYBaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo..getaddrinfocsj|i|Sr rrrr rrsz^BaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo..getaddrinfo_taskrr)rHr"rrhrPrr_r4rrr rr%test_create_connection_no_getaddrinfos zDBaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfocsZddfdd}|j_tj_tjj_jtdd} tjj |dS)NcsdgSrr rr r rr"szVBaseEventLoopWithSelectorTests.test_create_connection_connect_err..getaddrinfocsj|i|Sr rrrr rrsz[BaseEventLoopWithSelectorTests.test_create_connection_connect_err..getaddrinfo_taskrr) rHr"rrIrrrrrhrPr_rr rr"test_create_connection_connect_errs   zABaseEventLoopWithSelectorTests.test_create_connection_connect_errcsddfdd}|j_tj_tjj_jjtddt j d} tj |Wdn1sv0YdS)NcsddgSN)rr.rr+)0.0.0.1r)rr.rr+)z0.0.0.2rr rr r rr"szSBaseEventLoopWithSelectorTests.test_create_connection_multiple..getaddrinfocsj|i|Sr rrrr rrszXBaseEventLoopWithSelectorTests.test_create_connection_multiple..getaddrinfo_taskrrfamily) rHr"rrIrrrrrhrrrPr_rr rrtest_create_connection_multiples    z>BaseEventLoopWithSelectorTests.test_create_connection_multiplecsdd}||jj_ddfdd}|j_tj_tdjj_ jj t dd tj d d } t}j|Wdn1s0Yt|jd |jjjjdS) NcSs"|ddkrtd}d|_|dS)NrrErr)rstrerror)rerrr r rbinds z^BaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr..bindcsddgSrr rr r rr"szeBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr..getaddrinfocsj|i|Sr rrrr rrszjBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr..getaddrinfo_taskZErr2rrNir local_addrzMultiple exceptions: )rr!rrHr"rrIrrrrrhrrPr_r[rr startswithrZr)r4r$rrrrr rr1test_create_connection_multiple_errors_local_addrs    *zPBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addrc Cs|s|`tj|_|jj}t|j_d|jj_t|j_ d|jj _|j t j dd}|j |\}}zT|jd|jj\}}||d|j||d|jW|t|jn|t|j0tjrtj|_|j t j dd}|j |\}}z~|jjd\} | dd \} } || d || d|jj\}}||d|j||d|jW|t|jn|t|j0dS) NFr-rr-rrrrrrz ::(0\.)*1)rrr"r!rrIrH _add_readerr# _add_writerrr rr_connectrrr0rrrZr rrr3rr assertRegex) r4r$Zallow_inet_ptonrrrp_roaddresshostportr r r_test_create_connection_ip_addrsF         z>BaseEventLoopWithSelectorTests._test_create_connection_ip_addrZaixzDbpo-25545: IPv6 scope id and getaddrinfo() behave differently on AIXc Cstj|_|jj}tj|_t|j_d|jj_ t|j_ d|jj _ |j t j dd}|j|\}}zT|jd|jj\}}||d|j||d|jW|t|jn|t|j0dS)NFz fe80::1%1r)zfe80::1rrr.rr)rr"r!rrrrIrHrr#rrr rr_rrrr0rrZr r)r4r$rrrrrror r r!test_create_connection_ipv6_scopes$      z@BaseEventLoopWithSelectorTests.test_create_connection_ipv6_scopecCs||ddSrrr>r r rtest_create_connection_ip_addr7sz=BaseEventLoopWithSelectorTests.test_create_connection_ip_addrcCs||ddSrarr>r r r#test_create_connection_no_inet_pton;szBBaseEventLoopWithSelectorTests.test_create_connection_no_inet_ptonc Cs4tj|_|jj}t|j_d|jj_t|j_d|jj_dD]\}}|j t j d|}|j |\}}zX|j d|f|jj\}} || d|j|| d|jW|t|jq@|t|j0q@dD]N}|j t j d|}|t|j |Wdq1s$0YqdS)NF))httpr)shttprrrr)Znonsensesnonsense)rr"r!rrIrHrr#rrr rr_rrrr0rrrZr rrPr) r4r$rZservicerrrrrror r r#test_create_connection_service_name?s4         zBBaseEventLoopWithSelectorTests.test_create_connection_service_namecsLddfdd}|j_jjtddtjdd}tjj|dS) Ncs|dkrddgSgSdS)Nrrr )rrnrr r rr"_s zXBaseEventLoopWithSelectorTests.test_create_connection_no_local_addr..getaddrinfocsj|i|Sr rrrr rrfsz]BaseEventLoopWithSelectorTests.test_create_connection_no_local_addr..getaddrinfo_taskrrrr) rHr"rrhrrrPrr_rr rr$test_create_connection_no_local_addr^s  zCBaseEventLoopWithSelectorTests.test_create_connection_no_local_addrcs<dfdd}||_|}|j|}|j|dS)N)z00:01:02:03:04:05r.cs$||fksJdddddffgS)Nir.r+r )rrrnrrr rr"vszTBaseEventLoopWithSelectorTests.test_create_connection_bluetooth..getaddrinfo)r"rrHrr_)r4r$r"rrr rr test_create_connection_bluetoothps  z?BaseEventLoopWithSelectorTests.test_create_connection_bluetoothc stj_fdd}|jj_tj_jjj_jjjdtj_ Gdddfdd}|jj _tj }t }jj jj tddd |d }j|\}}|jj j||||d d|d jj jj tddd d |d}j|\}}|jj j||||d d |d jj jj tddd d|d}j|\}}|jj j||||d d|d dS)Ncs*j}|tjtjtjddfg|S)Nr+r)rHr\rrrrSOL_TCP)rnrr(rMr rmock_getaddrinfos   zkBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default..mock_getaddrinfoc@s eZdZdZddZddZdS)zqBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.._SelectorTransportMockNcSstSr )rrI)r4keyr r rget_extra_infoszBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.._SelectorTransportMock.get_extra_infocSs|jdSr )_sockrZrMr r rrZszwBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.._SelectorTransportMock.close)r@rArBrrrZr r r r_SelectorTransportMocksrcs|d}||_|Sr )rr)rprotocolZ sslcontextwaiterrrp)rr rmock_make_ssl_transports zrBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default..mock_make_ssl_transport python.orgrT)sslrF)Z server_sideserver_hostnamerzperl.com)rrrr+)rrIrHr"rrr\r!rrRANYrKrrrhr_rZr)r4rrrZhandshake_timeoutrrprr )rr4r2test_create_connection_ssl_server_hostname_defaultsj          zQBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_defaultcCsP|jjtdddd}|t|jj||jjtdddd}|t|jj|dS)Nrrr+)rrr0r r r4test_create_connection_no_ssl_server_hostname_errorss  zSBaseEventLoopWithSelectorTests.test_create_connection_no_ssl_server_hostname_errorscCs|jjtdddd}|t|jj||jjtdddd}|t|jj|t}|jjtddd|d}||j|t|jj|dS)Nr+rT)r)rr) rHrrhrPrr_rrrZ)r4rrr r r1test_create_connection_ssl_server_hostname_errorss  zPBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_errorscCsP|jjtdddd}|td|j|Wdn1sB0YdSr)rHrrhrrr_r0r r r3test_create_connection_ssl_timeout_for_plain_socketszRBaseEventLoopWithSelectorTests.test_create_connection_ssl_timeout_for_plain_socketcsXtfddfdd}|j_jtdd}tjj|dS)Ncs |dgSrRr r)rr rr"szQBaseEventLoopWithSelectorTests.test_create_server_empty_host..getaddrinfocsj|i|Sr rrrr rrszVBaseEventLoopWithSelectorTests.test_create_server_empty_host..getaddrinfo_taskr+r) rKrHr"rrhrPrr_r2)r4rrr )r"rr4rtest_create_server_empty_hosts z.ErrrN)r@rArBrr r r rr sr)rr.rr+)rit'Frr)rr"r!r#rrIrrrrHrrhrPr_r[rZrr4r$rZm_sockrr r rtest_create_server_cant_bindsz;BaseEventLoopWithSelectorTests.test_create_server_cant_bindcCs6g|j_d|j_|jjtdd}|t|jj|dS)NF) localhostrr) r"r!r#rHrrrPrr_r4r$rr r r)test_create_datagram_endpoint_no_addrinfo-s zHBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_no_addrinfocCsH|jjtdd}|t|jj||jjtdd}|t|jj|dS)Nrr)rr.rr )rHrrrPAssertionErrorr_r0r r r(test_create_datagram_endpoint_addr_error7s  zGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_addr_errorcCs>t|j_t|jj_|jjtjdd}| t|jj |dS)Nrr) remote_addr) rrIrHrrrrr DatagramProtocolrPr_r0r r r)test_create_datagram_endpoint_connect_errAs   zHBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_connect_errcstd|jdt|j_}g|_|jjfddddd}|j|\}}||j | |jj | dj dS)NTr\rHcsSr r r rr rrbPr:z^BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_allow_broadcast..r )r allow_broadcastr{)rrHrrIrr!rr_rYrrZrmr0rk)r4rrrprr rr-test_create_datagram_endpoint_allow_broadcastJs  zLBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_allow_broadcastcCs^tj|_t|j_|jjtjtjd}| t|jj ||jjtjdd}| t|jj |dS)Nrr r) rr"rrrHrr r rrPr_rr r r(test_create_datagram_endpoint_socket_err[s  zGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_socket_errzIPv6 not supported or enabledcCs*|jjtjddd}|t|jj|dS)Nr )rr)r rrHrr r rPrr_r0r r r0test_create_datagram_endpoint_no_matching_familyjs zOBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_no_matching_familycCsHt|jjj_|jjtjtj d}| t|jj || |jjj jdS)Nr)rrr! setblockingrrHrr r rrPr_r[rZrrr r r(test_create_datagram_endpoint_setblk_errrs   zGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_setblk_errcCs$|jtj}|t|jj|dSr rr0r r r-test_create_datagram_endpoint_noaddr_nofamily}szLBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_noaddr_nofamilycCshGdddt}tj|_t}|j_||j_|jj t dtj d}| ||jj |||jjdS)Nc@s eZdZdS)zSBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_cant_bind..ErrNrr r r rrsrr )rr)rrr"rrIr!rrrHrrrrPr_r[rZrrr r r'test_create_datagram_endpoint_cant_bindszFBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_cant_bindcsjttjtj}|djjfdd|d}j|\}}|j|j d|j dS)Nr cstdjdSNTr rrHr rMr rrbr:zSBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock..rr{) rrrrrHrr_rZrmr0rk)r4rrrprr rMr"test_create_datagram_endpoint_socks  zABaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockAF_UNIXzNo UNIX Socketscsdjjfddtjd}j|\}}|jjtjks.rr{) rHrrrr_rrrZrmr0rk)r4rrprr rMr'test_create_datagram_endpoint_sock_unixs zFBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_unixcstv}tjtjtjd}|||jjfdd|tjd}j |\}}|j |j Wdn1s0YdS)N)rcstdjdSrrr rMr rrbr:zaBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_existing_sock_unix..r) r Zunix_socket_pathrrrrrZrHrr_rm)r4pathrrrprr rMr0test_create_datagram_endpoint_existing_sock_unixs   zOBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_existing_sock_unixcCsGddd}|jjtd|d}|t|jj||jjtd|d}|t|jj||jjtd|d}|t|jj||jjtd|d}|t|jj||jjtd|d }|t|jj||jjtd |d }|t|jj||jjtd |d }|t|jj|dS) Nc@seZdZejZdS)z\BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockopts..FakeSockN)r@rArBrrrr r r rFakeSocksrr )rr)r rr.)rr)protor)flagsrT)rr)rr)rHrrrPrr_)r4rrr r r+test_create_datagram_endpoint_sock_sockoptss:zJBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockoptscs4jjfdddd}j|\}}|d}ttd}|rV|tjtj |tjtj | j|j  d|jjjfddd|d d }j|\}}|d}|tjtj|r|tjtj |tjtj | j|j  d|jdS) NcstdjdSrrr rMr rrbr:zWBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockopts..r rrrr{cstdjdSrrr rMr rrbr:T)rrr)rHrr_rrrrY getsockoptrr SO_BROADCASTrZrmr0rkrr[)r4rrprrreuseport_supportedr rMr&test_create_datagram_endpoint_sockoptss`     zEBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockoptscsTjjfddddd}tj|Wdn1sF0YdS)NcstdjdSrrr rMr rrb r:zbBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_reuse_address_error..r TrZ reuse_address)rHrrPrr_r0r rMr1test_create_datagram_endpoint_reuse_address_errors  zPBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_reuse_address_errorcs|jjfddddd}tDj|\}}|j|jd|jWdn1sn0YdS)NcstdjdSrrr rMr rrbr:zdBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_reuse_address_warning..r Fr'r{) rHrrzr{r_rZrmr0rk)r4rrprr rMr3test_create_datagram_endpoint_reuse_address_warnings  zRBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_reuse_address_warningcs@|`t|j_jjfddddd}tjj |dS)Ncs tjdSrrr rMr rrb$r:z\BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_nosoreuseport..r Trr) rrrIrr!rHrrPrr_rr rMr+test_create_datagram_endpoint_nosoreuseports  zJBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_nosoreuseportc sfdd}||_t|jj_}tj_djj_t td}jj fddd|d}j |\}}z:| d|jj |j |j|jd W|tjn|tj0dS) NcsddS)Nz"should not have called getaddrinfo)ZfailrrMr rr",szYBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addr..getaddrinfoFrcs tjdSrrr rMr rrb6r:zVBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addr..r9r*)rr r)r"rrIrr!rrHrr#rrr_rrrrrZr r)r4r$r"rr%rrrr rMr%test_create_datagram_endpoint_ip_addr*s,       zDBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addrcCs2t}t|j_|jt|||j j dSr ) rrIBlockingIOErroracceptrrH_accept_connectionrhrYrZrr4rr r rtest_accept_connection_retryDs z;BaseEventLoopWithSelectorTests.test_accept_connection_retryrc Cst}d|j_ttjd|j_t|j _ t|j _ |j t |||jj||jj|j j d|j j tjtjt |ddtjtjdS)N zToo many open files)rrIfilenor!rrZEMFILEr.rrHZ_remove_readerrr/rhr[rrrYrZrrZACCEPT_RETRY_DELAYr)r4Zm_logrr r r test_accept_connection_exceptionKs  z?BaseEventLoopWithSelectorTests.test_accept_connection_exceptionc Cs|ttjdd}Wdn1s.0Y|jd|}|}||j||fD]0}|t |j |Wdn1s0Y|t |j |Wdn1s0Y|t |j d|Wdn1s0Y|t (|j |jd|Wdn1sH0Y|t &|j|jd|Wdqb1s0YqbdS)NcSsdSr r r r r rsimple_coroutine_szLBaseEventLoopWithSelectorTests.test_call_coroutine..simple_coroutineTr)rzr{r coroutinerHrrrZrPrr~rrrrr_re)r4r5Z coro_funcZcoro_objrAr r rtest_call_coroutine]s( (   * * . 8  z2BaseEventLoopWithSelectorTests.test_call_coroutinecCsdd}dd}t|j|jdd|j_|j||j|j|jjd^}}| |t |dtj ||j|jd |j|jjd^}}| |t |d dS) NcSs |dSr rrr r r stop_loop_cbvszLBaseEventLoopWithSelectorTests.test_log_slow_callbacks..stop_loop_cbcs |dSr r8rr r rstop_loop_coroyszNBaseEventLoopWithSelectorTests.test_log_slow_callbacks..stop_loop_coroTgrz4^Executing took .* seconds$rz4^Executing took .* seconds$) r rLrHrZslow_callback_durationr~r^warningrrtupler)r4Zm_loggerr9r:fmtrnr r rtest_log_slow_callbacksts"    z6BaseEventLoopWithSelectorTests.test_log_slow_callbacks)Jr@rArBrFrr'rr)rrrrrrunittest skipUnlessrrrrr3rrrrrrrrZskipIfrplatformrrrrrrrrrrrrrrrrrrrrr rrrrrrrrZskip_unless_bind_unix_socketrr"r&r(r)r+r,r1r4r7r>rgr r rNrrs         +     I                 /    rc@seZdZddZdS)RunningLoopTestscCs~dd}t}t}zN|td|||Wdn1sJ0YW||n||0dS)Ncs |dSr )r^rr r rrunnersz@RunningLoopTests.test_running_loop_within_a_loop..runnerzwhile another loop is running)r r6rr]r_rZ)r4rCrHZ outer_loopr r rtest_running_loop_within_a_loops. z0RunningLoopTests.test_running_loop_within_a_loopN)r@rArBrDr r r rrBsrBcseZdZddZGdddejZefddZefddZ fd d Z d(d d Z ddZ ddZ ddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'ZZS))BaseLoopSockSendfileTestss12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcdeic@s4eZdZddZddZddZddZd d Zd S) z!BaseLoopSockSendfileTests.MyProtocCs(d|_d|_t|_||_d|_dSra)rTclosed bytearrayrvr\rrp)r4rHr r rrns  z*BaseLoopSockSendfileTests.MyProto.__init__cCsd|_||_dSr)rTrprrr r rrssz1BaseLoopSockSendfileTests.MyProto.connection_madecCs|j|dSr )rvextendrur r rrwsz/BaseLoopSockSendfileTests.MyProto.data_receivedcCsd|_|jdd|_dSr)rFrrrpr}r r rr~s z1BaseLoopSockSendfileTests.MyProto.connection_lostcs|jIdHdSr rrMr r rrsz-BaseLoopSockSendfileTests.MyProto.wait_closedN)r@rArBrnrsrwr~rr r r rrhs rhcsTtj|_dt_ttjd}||jWdn1s<0Yt dS)Ni@wb) r!SENDFILE_FALLBACK_READBUFFER_SIZE'_BaseLoopSockSendfileTests__old_bufsizeopenrTESTFNrqDATArE setUpClass)clsfprNr rrOs *z$BaseLoopSockSendfileTests.setUpClasscs"|jt_ttjtdSr )rKrrJrunlinkrMrE tearDownClass)rPrNr rrSs z'BaseLoopSockSendfileTests.tearDownClasscsJddlm}||_||jttjd|_||jj t dS)Nr)BaseSelectorEventLooprb) Zasyncio.selector_eventsrTrHrLrLrrMfilerrZrErF)r4rTrNr rrFs   zBaseLoopSockSendfileTests.setUpFcCs*ttjtj}||||j|Sr )rrrrrrZ)r4blockingrr r r make_sockets  z%BaseLoopSockSendfileTests.make_socketcCs |j|Sr )rHr_r0r r rrsz"BaseLoopSockSendfileTests.run_loopc sjjjfddtjdtjdj d }t dD]H}zj |Wn&t ytdYqPYqP0qqPj |fdd}|fS) NcsSr r r )r r rrbr:z3BaseLoopSockSendfileTests.prepare..rrr2g?csDjdur@jdSr )rZrrrpr r r4Zserverrr rcleanups   z2BaseLoopSockSendfileTests.prepare..cleanup)rXrhrHrrrZHOSTrrr getsocknamerrrr rr)r4rrrZr rYrprepares"      z!BaseLoopSockSendfileTests.preparec Csx|\}}|tjd*||j||jddWdn1sJ0Y||j d||j ddS)Nsendfile is not availablerr:) r\rr SendfileNotAvailableErrorrrHZ_sock_sendfile_nativerVr0rvtellr4rr r r r"test__sock_sendfile_native_failures $zsX        aTy5