Ϫf` ddlmZmZddlmZddlmZereZneZd dZ e GddeeZ e je jy) ) TYPE_CHECKINGList)SynchronousTestCase)ReactorBuilderNcy)z0 Do-nothing callable. Stub for testing. Nr F/usr/lib/python3/dist-packages/twisted/internet/test/test_cfreactor.pynoopr sr c6eZdZdZdgZddZddZddZddZy) CoreFoundationSpecificTestszN Tests for platform interactions of the CoreFoundation-based reactor. z$twisted.internet.cfreactor.CFReactorNc|j}|jd|j|jdt|j ||j |j dy)zO CFReactor's simulation timer is None after CFReactor crashes. rdN) buildReactor callLatercrashr runReactorassertIs_currentSimulator)selfrs r test_whiteboxStopSimulatingz7CoreFoundationSpecificTests.test_whiteboxStopSimulatingsR     Aqww C  a))40r c|j}|jdt}|jdfd }dfd jd||j|j |j |gy)a\ callLater should not leak global state into CoreFoundation which will be invoked by a different reactor running the main loop. @note: this test may actually be usable for other reactors as well, so we may wish to promote it to ensure this invariant across other foreign-main-loop reactors. rNc*jdy)Nr)r)r2r2stopsr stopBlockingzGCoreFoundationSpecificTests.test_callLaterLeakage..stopBlocking3s LLF #r c&jyN)stop)rsr rzACoreFoundationSpecificTests.test_callLaterLeakage..r2stop6s GGIr returnN)rrr r assertEqualgetDelayedCalls)rrdelayedrrrs @@r test_callLaterLeakagez1CoreFoundationSpecificTests.test_callLaterLeakage&sr    ++a&     $  Q %  **,wi8r cN|j}g}|jd|jd|jdt}|j |j |j d|j|j|g|j|dgy)an C{.iterate()} should remove the CFTimer that will run Twisted's callLaters from the loop, even if one is still pending. We test this state indirectly with a white-box assertion by verifying the C{_currentSimulator} is set to C{None}, since CoreFoundation does not allow us to enumerate all active timers or sources. rrrN) rrappendr iteraterrr$r%)rrxr&s r test_whiteboxIteratez0CoreFoundationSpecificTests.test_whiteboxIterate=s     Aqxx#++c4(  a))40 **,wi8 QC r c|jgdfd dfd }jdj|j|j dgy)zS The loop can wake up just fine even if there are no timers in it. NcHjjdy)Nyes)r!r))rstoppedsr doStopz9CoreFoundationSpecificTests.test_noTimers..doStopUs FFH NN5 !r c(jyr )callFromThread)r1rsr sleepThenStopz@CoreFoundationSpecificTests.test_noTimers..sleepThenStopYs  V $r rr/r")rr callInThreadrunr$)rr4r1rr0s @@@r test_noTimersz)CoreFoundationSpecificTests.test_noTimersNsU     " % Aq~~}5  5'*r r") __name__ __module__ __qualname____doc__ _reactorsrr'r,r7r r r rrs%88I19.!"+r rr")typingrrtwisted.trial.unittestr reactormixinsrfakeBaseobjectr rglobalsupdatemakeTestCaseClassesr r r rEsT&6)"HH M+.(M+` ,@@BCr