a  ze.*?) object at (?P
.*?)\[(?P(set|unset|locked|unlocked)(, value:\d)?(, waiters:\d+)?)\]>\ZcCstddSN)asyncioZset_event_loop_policyrrP/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_asyncio/test_locks.pytearDownModulesrcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZZS) LockTestscst||_dSrsupersetUp new_test_looploopself __class__rrr s zLockTests.setUpcCst}|ttj|d}Wdn1s40Y||j||ttj|jd}Wdn1sz0Y||j|jdSNr) rMock assertWarnsDeprecationWarningrLockassertIs_looprrrlockrrrtest_ctor_loops * ,zLockTests.test_ctor_loopcCs(t|jt}||j|jdSr)rset_event_looprrrrrrrrrtest_ctor_noloop's zLockTests.test_ctor_noloopcCs|ttj|jd}Wdn1s.0Y|t|d|t t||j | |t|d|t t|dS)Nrz [unlocked]> [locked]>) rrrrr assertTruereprendswithRGX_REPRmatchrun_until_completeacquirerrrr test_repr,s ,zLockTests.test_reprcs|t0tj|jdtjfdd}Wdn1s@0Y|td|j|Wdn1sz0Y| dS)Nrc3s EdHSrrrrrr acquire_lock:sz)LockTests.test_lock..acquire_lockobject is not iterable) rrrrr coroutineassertRaisesRegex TypeErrorr' assertFalselockedrr+rr*r test_lock6s ,,zLockTests.test_lockcst}|tNtj|dtj|dtj|dtj|dg}tj fdd}Wdn1sp0Y|D] }| || | q~dS)Nrc 3stdEdH|td:|EdHWdn1sL0YWdn1sj0Y|dS)Ng{Gz?r,)rsleepr0r1r.r/r*rrrtestQs <z3LockTests.test_lock_by_with_statement..test) rnew_event_looprrrr Condition SemaphoreBoundedSemaphorer-r'r0r1)rrZ primitivesr5Z primitiverrrtest_lock_by_with_statementFs      , z%LockTests.test_lock_by_with_statementcs|ttj|jdWdn1s.0Yg}||jfdd}fdd}fdd}|j||}|j||}t |j| g| t |j| dg|t |j| dg||j||} t |j| dd g| t |j| gd ||| |||| |||| ||dS) NrcsIdHr|ddSNTr(appendresultr*rrc1hs z"LockTests.test_acquire..c1csIdHr|ddSNTr=r?r*rrc2ms z"LockTests.test_acquire..c2csIdHr|ddSNTr=r?r*rrc3rs z"LockTests.test_acquire..c3r<rCr<rCrF)rrrrrr"r'r( create_task test_utils run_briefly assertEqualreleasedoner@rr@rArDrGt1t2t3rr*r test_acquireas: ,         zLockTests.test_acquirecCs|ttj|jd}Wdn1s.0Y||j||j|}|j |j | tj |jj|| |jdSr)rrrrrr"r'r(rI call_sooncancel assertRaisesCancelledErrorr0_waiters)rrZtaskrrrtest_acquire_cancels ,zLockTests.test_acquire_cancelcsH|ttj|jdWdn1s.0Yfdd}|j}|j|d|}t|j| |j|dd}t|j| t j d|j|dd}t|j| t j d|d|| j d t|j| | || || |dS) Nrcs<IdHz|dur"|IdHWn 0dSr)r(rM)nameZblockerr*rrlockits  z*LockTests.test_cancel_race..lockitABr<CrCr)rrrrrZ create_futurerIrJrKr"r1rLlenrX set_resultrU cancelledr0rN)rr[fatatbtcrr*rtest_cancel_races* ,       zLockTests.test_cancel_racecs.ttjjdWdn1s.0Yddfdd}fdd}fddj|}j|j|}j|}tj| tjtj d  d  o| | tj| dS) Nrrcs"d7IdHd7dSNr<)r(r) call_countr lock_countrrr[sz2LockTests.test_cancel_release_race..lockitcsIdHjdSr)r(rrTr)rrtriggerrrlockandtriggersz:LockTests.test_cancel_release_race..lockandtriggercsdSr)rUrMr)rrPrrrjsz3LockTests.test_cancel_release_race..triggerr<rF) rrrrrrIrJrKr"rNrLrarU)rr[rkt0rQrRr)rhrrirrPrjrtest_cancel_release_races* ,      z"LockTests.test_cancel_release_racecCs|ttj|jd}Wdn1s.0Y|j|}t|j| | |j|}t|j| t |j d|j|}||t|j| | | || |dS)Nrr<)rrrrrrIr(rJrKr"r1rLr_rXrMrUrNra)rrrcrdrerrrtest_finished_waiter_cancelleds ,   z(LockTests.test_finished_waiter_cancelledcCsJ|ttj|jd}Wdn1s.0Y|t|jdSr)rrrrrrV RuntimeErrorrMrrrrtest_release_not_acquireds ,z#LockTests.test_release_not_acquiredcCsp|ttj|jd}Wdn1s.0Y|j|||| | |dSr) rrrrrr'r(r"r1rMr0rrrrtest_release_no_waiterss  ,z!LockTests.test_release_no_waiterscsfdd}j|dS)Nc snt}||4IdH$|WdIdHq\1IdHsR0Y|dSr)rrr0r1r"r*rrrf)s 8z)LockTests.test_context_manager..frr'rrrrrrtest_context_manager(s zLockTests.test_context_manager)__name__ __module__ __qualname__r rr r)r3r:rSrYrfrmrnrprqru __classcell__rrrrr s   4 01 r cs\eZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ Z S) EventTestscst||_dSrr rrrrr 7s zEventTests.setUpcCst}|ttj|d}Wdn1s40Y||j||ttj|jd}Wdn1sz0Y||j|jdSr) rrrrrEventrrr)rrevrrrr;s * ,zEventTests.test_ctor_loopcCs(t|jt}||j|jdSr)rrrr{rrrr|rrrr Es zEventTests.test_ctor_noloopcCs|ttj|jd}Wdn1s.0Y|t|dt t|}| | dd| |t|d|t t||j t|dt|v|t t|dS)Nrz[unset]>extrasZunsetz[set]> waiters:1)rrrr{rr"r#r$r%r&rLgroupsetrXr>rr)rr|r&rrrr)Js ,zEventTests.test_reprcs2|ttj|jdWdn1s.0Y|g}fdd}fdd}fdd}|j||}|j||}t |j| g||j||} t |j| gd|| | ||| | ||| | ||dS) NrcsIdHr|ddSrgwaitr>r?r|rrrA`sz EventTests.test_wait..c1csIdHr|ddS)NrCrr?rrrrDdsz EventTests.test_wait..c2csIdHr|ddS)NrFrr?rrrrGhsz EventTests.test_wait..c3)rFr<rC)rrrr{rr0is_setrIrJrKrLrr"rNZ assertIsNoner@rOrrr test_waitYs* ,      zEventTests.test_waitcCs^|ttj|jd}Wdn1s.0Y||j|}||dSr) rrrr{rrr'rr")rr|resrrrtest_wait_on_sets  ,zEventTests.test_wait_on_setcCsz|ttj|jd}Wdn1s.0Y|j|}|j|j| tj |jj || |j dSr)rrrr{rrIrrTrUrVrWr'r0rX)rr|rrrrtest_wait_cancels ,zEventTests.test_wait_cancelcCsv|ttj|jd}Wdn1s.0Y|||||| ||dSr) rrrr{rr0rrr"clearr}rrr test_clears ,zEventTests.test_clearcs|ttj|jdWdn1s.0Yg}fdd}|j||}t|j|g|  |   |dt jt|j|dg||dt j||||dS)NrcsIdHr|ddSr;rr?rrrrAs z.EventTests.test_clear_with_waiters..c1r<r)rrrr{rrIrJrKrLrrr0rr_rXr"rNr@rr@rAtrrrtest_clear_with_waiterss$ ,    z"EventTests.test_clear_with_waiters) rvrwrxr rr r)rrrrrryrrrrrz5s  &  rzcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZZS)'ConditionTestscst||_dSrr rrrrr s zConditionTests.setUpcCsnt}|tHtj|d}||j|tj|jd}||j|jWdn1s`0YdSr) rrrrrr7rrr)rrcondrrrrs   zConditionTests.test_ctor_loopcCs(t|jt}||j|jdSr)rrrr7rrrrrrrr s zConditionTests.test_ctor_noloopcs|ttj|jdWdn1s.0Yg}fdd}fdd}fdd}|j||}|j||}|j||}t|j|g|| | |j t|j|g|| t|j|dg|| d t|j|dg|| t|j|dd g|| t|j|gd || | || || || || || |dS) Nrcs*IdHIdHr&|ddSr;r(rr>r?rrrrAs z$ConditionTests.test_wait..c1cs*IdHIdHr&|ddSrBrr?rrrrDs z$ConditionTests.test_wait..c2cs*IdHIdHr&|ddSrErr?rrrrGs z$ConditionTests.test_wait..c3r<rCrH)rrrr7rrIrJrKrLr0r1r"r'r(notifyrMrNr@rOrrrrsN ,            zConditionTests.test_waitcCs|ttj|jd}Wdn1s.0Y|j||j|}|j |j | tj |jj|| |j||dSr)rrrr7rr'r(rIrrTrUrVrWr0rXr"r1)rrrrrrrs , zConditionTests.test_wait_cancelcCs|ttj|jd}Wdn1s.0Y|j||||j | }t |j| ||j|||||j|j|j|jz|j|WntjyYn0||dSr)rrrr7rr'r(r"r1rIrrJrKr0rrTrUrMrW)rrZ wait_taskrrrtest_wait_cancel_contesteds" , z)ConditionTests.test_wait_cancel_contestedcs|ttj|jdWdn1s.0Ydfdd}tj||jd}t|j|j  t|j| t|j t|j| || dS)NrFc sN4IdH(dIdHWdIdHqJ1IdHs@0YdS)NT)rrrZwaitedrr wait_on_cond<szBConditionTests.test_wait_cancel_after_notify..wait_on_cond)rrrr7rZ ensure_futurerJrKr'r(rrUrMr"ra)rrwaiterrrrtest_wait_cancel_after_notify6s ,    z,ConditionTests.test_wait_cancel_after_notifycCsR|ttj|jd}Wdn1s.0Y|t|jj|dSr) rrrr7rrVror'rrrrrtest_wait_unacquiredPs  , z#ConditionTests.test_wait_unacquiredcs|ttj|jdWdn1s.0Ydfddg}fdd}|j||}t|j|g||j   t|j|g|d|j   t|j|dg|| || |dS) NrFcsSrrr)presultrr predicate\sz/ConditionTests.test_wait_for..predicatecs4IdHIdHr0|ddSr;)r(wait_forr>rMr?)rrrrrAas  z(ConditionTests.test_wait_for..c1Tr<rrrr7rrIrJrKrLr'r(rrMr"rNr@rr)rrrr test_wait_forWs, ,      zConditionTests.test_wait_forcCs~|ttj|jd}Wdn1s.0Y|j|dd}|gd||t |jj|dddS)NrcSsgdS)NrHrrrrrz9ConditionTests.test_wait_for_unacquired..rHcSsdS)NFrrrrrrr) rrrr7rr'rrLrVro)rrrrrrtest_wait_for_unacquired}s , z'ConditionTests.test_wait_for_unacquiredcs|ttj|jdWdn1s.0Yg}fdd}fdd}fdd}|j||}|j||}|j||}t|j|g||j  d t|j|dg||j  d d  t|j|gd || || || || || || |dS) Nrcs2IdHIdHr.|ddSr;r(rr>rMr?rrrrAs  z&ConditionTests.test_notify..c1cs2IdHIdHr.|ddSrBrr?rrrrDs  z&ConditionTests.test_notify..c2cs2IdHIdHr.|ddSrErr?rrrrGs  z&ConditionTests.test_notify..c3r<irHrrOrrr test_notifys8 ,          zConditionTests.test_notifycs|ttj|jdWdn1s.0Yg}fdd}fdd}|j||}|j||}t|j|g||j   t|j|ddg|| || || || |dS)Nrcs2IdHIdHr.|ddSr;rr?rrrrAs  z*ConditionTests.test_notify_all..c1cs2IdHIdHr.|ddSrBrr?rrrrDs  z*ConditionTests.test_notify_all..c2r<rC)rrrr7rrIrJrKrLr'r( notify_allrMr"rNr@)rr@rArDrPrQrrrtest_notify_alls$ ,     zConditionTests.test_notify_allcCsJ|ttj|jd}Wdn1s.0Y|t|jdSr)rrrr7rrVrorrrrrtest_notify_unacquireds ,z%ConditionTests.test_notify_unacquiredcCsJ|ttj|jd}Wdn1s.0Y|t|jdSr)rrrr7rrVrorrrrrtest_notify_all_unacquireds ,z)ConditionTests.test_notify_all_unacquiredcCs|ttj|jd}Wdn1s.0Y|dt|v|tt||j | |dt|v|j t |dt|v|tt||j t |dt|v|tt|dS)Nrunlockedr1r waiters:2)rrrr7rr"r#r%r&r'r(rXr>rrrrrrr)s ,zConditionTests.test_reprcsfdd}j|dS)Nc snt}||4IdH$|WdIdHq\1IdHsR0Y|dSr)rr7r0r1r"rrrrrrs 8z.ConditionTests.test_context_manager..frsrtrrrrus z#ConditionTests.test_context_managercCsj|t.tj|jd}tj||jd}Wdn1s>0Y||j|||j|jdSr) rrrrrr7r_lockr)rrrrrrtest_explicit_lock s  .z!ConditionTests.test_explicit_lockc Cs|}||j|tVtj|jd}|t tj ||dWdn1s\0YWdn1sz0YdSr) r addCleanupcloserrrrrrV ValueErrorr7rrrrtest_ambiguous_loopss    z#ConditionTests.test_ambiguous_loopscs\tjfdd}t|Wdn1sN0YdS)Nc stjd}|4IdHZtj(tj|ddIdHWdn1sT0YWdIdHq1IdHs~0YdS)Nrg?)timeout)rr7rV TimeoutErrorrr)Z conditionrrrr task_timeouts z:ConditionTests.test_timeout_in_block..task_timeout)rr6rrrrr')rrrrrtest_timeout_in_blocks   z$ConditionTests.test_timeout_in_block)rvrwrxr rr rrrrrrrrrrrr)rurrrryrrrrrs&  @ & 5% rcs|eZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZZS)SemaphoreTestscst||_dSrr rrrrr )s zSemaphoreTests.setUpcCst}|ttj|d}Wdn1s40Y||j||ttj|jd}Wdn1sz0Y||j|jdSr) rrrrrr8rrr)rrsemrrrr-s * ,zSemaphoreTests.test_ctor_loopcCs(t|jt}||j|jdSr)rrrr8rrrrrrrr 7s zSemaphoreTests.test_ctor_noloopcCsL|t tjd|jd}Wdn1s00Y||dS)Nrr)rrrr8rr"r1rrrrtest_initial_value_zero<s .z&SemaphoreTests.test_initial_value_zerocCs|ttj|jd}Wdn1s.0Y|t|d|t t||j | |t|d|dt|v|t t||j t|dt|v|t t||j t|dt|v|t t|dS)Nrz[unlocked, value:1]>r!waitersrr)rrrr8rr"r#r$r%r&r'r(rXr>rrrrrrr)As ,zSemaphoreTests.test_reprcs|ttj|jdWdn1s.0Y|dj|t"tjfdd}Wdn1sx0Y|t d|j |Wdn1s0Y| |djdS)Nrr<c3s EdHSrrrrrrr+Zsz3SemaphoreTests.test_semaphore..acquire_lockz"'Semaphore' object is not iterable) rrrr8rrL_valuer-r.r/r'r0r1r2rrrtest_semaphoreTs , ,,zSemaphoreTests.test_semaphorecCs|ttjddS)N)rVrrr8rrrrtest_semaphore_valuegsz#SemaphoreTests.test_semaphore_valuec s|t tjd|jdWdn1s00Yg}||j||j| fdd}fdd}fdd}fd d }|j ||}|j ||}|j ||}t |j| d g|| | d tj| d j|j ||} | d jt |j| d j| dt|| | d tj| d j||||||| g} dd| D} |d t| |jtj| dS)NrFrcsIdH|ddSr;r=r?rrrrAss z'SemaphoreTests.test_acquire..c1csIdH|ddSrBr=r?rrrrDxs z'SemaphoreTests.test_acquire..c2csIdH|ddSrEr=r?rrrrG}s z'SemaphoreTests.test_acquire..c3csIdH|ddS)NTr=r?rrrc4s z'SemaphoreTests.test_acquire..c4r<rCrcSs g|]}|r|r|qSr)rNr@.0rrrr rz/SemaphoreTests.test_acquire..)rrrr8rr"r'r(r0r1rIrJrKrLr_rXrrMrNr@Zgather) rr@rArDrGrrPrQrRt4Z race_tasksZ done_tasksrrrrSjsF .       zSemaphoreTests.test_acquirecCs|ttj|jd}Wdn1s.0Y|j||j|}|j|j | tj |jj|| |j ptdd|j DdS)Nrcss|]}|VqdSrrN)rrrrr rz5SemaphoreTests.test_acquire_cancel..)rrrr8rr'r(rIrTrUrVrWr"rXall)rrr(rrrrYs , z"SemaphoreTests.test_acquire_cancelcCs|t tjd|jd}Wdn1s00Y|j|}|j|}|j|}|j|}t|j| | | t|jt dd||fD}| |d| | t|jdS)Nrvaluercss|]}|VqdSrrrrrrrrzCSemaphoreTests.test_acquire_cancel_before_awoken..r<) rrrr8rrIr(rJrKrMrUsumrL)rrrPrQrRrZnum_donerrr!test_acquire_cancel_before_awokens  .   z0SemaphoreTests.test_acquire_cancel_before_awokencCs|t tjd|jd}Wdn1s00Y|j|}|j|}t|j| | t|j| | dS)Nrr) rrrr8rrIr(rJrKrMrUr"r1)rrrPrQrrrtest_acquire_hangs .  z SemaphoreTests.test_acquire_hangcCsJ|ttj|jd}Wdn1s.0Y|t|jdSr)rrrr9rrVrrMrrrrrps ,z(SemaphoreTests.test_release_not_acquiredcCsp|ttj|jd}Wdn1s.0Y|j|||| | |dSr) rrrr8rr'r(r"r1rMr0rrrrrqs  ,z&SemaphoreTests.test_release_no_waiters)rvrwrxr rr rr)rrrSrYrrrprqryrrrrr's  > r__main__)ZunittestrrerZtest.test_asynciorrJZ STR_RGX_REPRcompiler%rZTestCaser rzrrrvmainrrrrs(    nE