ó {G_Tc@€sddlmZddlZddlZddlZddlZddlmZyddlZddl Z Wne k r‹dZdZ nXej dƒZ eje dƒdejfd„ƒYƒZeje oÕedƒdejfd „ƒYƒZd „Zed kreƒndS( iÿÿÿÿ(twith_statementN(t test_supportt _testcapis!Threading required for this test.tTestPendingCallscB€s8eZd„Zdd„Zd„Zd„Zd„ZRS(c€sa‡fd†}xKt|ƒD]=}tjtjƒdƒxtrXtj|ƒr<Pq<q<WqWdS(Nc€sˆjdƒdS(N(tappendtNone((tl(s*/usr/local/lib/python2.7/test/test_capi.pytcallbacksg{®Gáz”?(trangettimetsleeptrandomtTrueRt_pending_threadfunc(tselfRtnRti((Rs*/usr/local/lib/python2.7/test/test_capi.pytpendingcalls_submits  cC€s×d}x¦t|ƒ|kr®tr>tjr>dt|ƒfGnxtdƒD]}||}qKW|r{|jjƒ r{q n|d7}|j|dkd|t|ƒfƒq WtrÓtjrÓdt|ƒfGHndS(Nis(%i)ièii's(timeout waiting for %i callbacks, got %i(tlentFalseRtverbosetxrangeteventtis_sett assertTrue(RRRtcontexttcountRta((s*/usr/local/lib/python2.7/test/test_capi.pytpendingcalls_wait&s cC€sød}g}dtfd„ƒY}|ƒ}g|_d|_||j|_d|_tjƒ|_tjƒ|_ xLt |jƒD];}tj d|j d|fƒ}|j ƒ|j|ƒq„W|j|j||ƒx|D]}|jƒqàWdS(Ni tfoocB€seZRS((t__name__t __module__(((s*/usr/local/lib/python2.7/test/test_capi.pyR=siittargettargs(tobjectRRtnThreadst nFinishedt threadingtLocktlocktEventRRtThreadtpendingcalls_threadtstartRRtjoin(RRtthreadsRRRtt((s*/usr/local/lib/python2.7/test/test_capi.pyttest_pendingcalls_threaded9s"      c C€s„z|j|j|jƒWd|j8|jd7_|j}trZtjrZdG|GHnWdQX||jkr|j j ƒnXdS(Nisfinished threads: ( RRRR'R$RRRR#Rtset(RRR$((s*/usr/local/lib/python2.7/test/test_capi.pyR*Ps  cC€s0g}d}|j||ƒ|j||ƒdS(Ni@(RR(RRR((s*/usr/local/lib/python2.7/test/test_capi.pyttest_pendingcalls_non_threaded\sN(RRRRRR/R*R1(((s*/usr/local/lib/python2.7/test/test_capi.pyRs     tTestThreadStatecB€seZejd„ƒZRS(c€s@‡fd†}|ƒtjd|ƒ}|jƒ|jƒdS(Nc€s_g‰‡fd†}tj|ƒ|}}tjdƒˆjˆjtjƒƒddƒdS(Nc€sˆjtjƒƒdS(N(Rtthreadt get_ident((tidents(s*/usr/local/lib/python2.7/test/test_capi.pyRpsiis/Couldn't find main thread correctly in the list(Rt_test_thread_stateR R t assertEqualRR3R4(RRtb(R(R5s*/usr/local/lib/python2.7/test/test_capi.pyR ms   R (R%R)R+R,(RR R.((Rs*/usr/local/lib/python2.7/test/test_capi.pyttest_thread_statejs   (RRRt reap_threadsR9(((s*/usr/local/lib/python2.7/test/test_capi.pyR2gscC€s™x‚ttƒD]t}|jdƒr tt|ƒ}tjrFdG|GHny |ƒWqtjk r}tjtj ƒd‚qXq q Wtj t t ƒdS(Nttest_tinternali( tdirRt startswithtgetattrRRterrort TestFailedtsystexc_infot run_unittestRR2(tnamettest((s*/usr/local/lib/python2.7/test/test_capi.pyt test_main€s   !t__main__(t __future__RRBR R tunittestRFRR3R%t ImportErrorRt import_moduleRt skipUnlesstTestCaseRR2RGR(((s*/usr/local/lib/python2.7/test/test_capi.pyts&       R