ó {G_Tc@sddlZddlZddlZddlZddlmZdejfd„ƒYZddd„ƒYZdefd„ƒYZ d ejfd „ƒYZ d e fd „ƒYZ d e fd„ƒYZ d„Z d„Ze eƒZdd„Zd„Zd„ZedkreƒndS(iÿÿÿÿN(t test_supporttTestGetProfilecBs,eZd„Zd„Zd„Zd„ZRS(cCstjdƒdS(N(tsyst setprofiletNone(tself((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytsetUp scCstjdƒdS(N(RRR(R((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttearDown scCs|jtjƒƒdS(N(t assertIsNoneRt getprofile(R((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt test_emptyscCs0d„}tj|ƒ|jtjƒ|ƒdS(NcWsdS(N((targs((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytfns(RRtassertIsR (RR ((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt test_setgets  (t__name__t __module__RRR R(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRs   t HookWatchercBs/eZd„Zd„Zdd„Zd„ZRS(cCsg|_g|_dS(N(tframestevents(R((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt__init__s cCs;|dks$|dks$|dkr7|j||ƒndS(Ntcalltreturnt exception(t add_event(Rtframeteventtarg((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytcallbacks   cCsŠ|dkrtjdƒ}ny|jj|ƒ}Wn0tk rft|jƒ}|jj|ƒnX|jj||t |ƒfƒdS(sAdd an event to the log.iN( RRt _getframeRtindext ValueErrortlentappendRtident(RRRtframeno((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR$s  cCsQt|jjƒttƒg}d|_g|jD]}|d|kr1|^q1S(sRemove calls to add_event().iN(R"Rtim_funcRRR(Rt disallowedtitem((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt get_events1s N(RRRRRRR'(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRs   tProfileSimulatorcBsneZd„Zd„Zd„Zd„Zd„Zd„Zied6ed6ed6ed 6ed 6ed 6ZRS( cCs#||_g|_tj|ƒdS(N(ttestcasetstackRR(RR)((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR:s  cCs|j|||ƒdS(N(tdispatch(RRRR((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?scCs$|jd|ƒ|jj|ƒdS(NR(RR*R!(RR((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt trace_callCscCs!|jd|ƒ|jjƒdS(NR(RR*tpop(RR((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt trace_returnGscCs|jjdƒdS(Ns2the profiler should never receive exception events(R)tfail(RR((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttrace_exceptionKs cCsdS(N((RR((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt trace_passOsRRRtc_calltc_returnt c_exception( RRRRR,R.R0R1R+(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR(9s      t TestCaseBasecBseZd„ZRS(cCsQt||jƒƒ}||krM|jdtj|ƒtj|ƒfƒndS(Ns'Expected events: %s Received events: %s(tcapture_eventst new_watcherR/tpprinttpformat(RtcallabletexpectedR((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt check_events]s  (RRR<(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR5\stProfileHookTestCasecBs†eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(cCstƒS(N(R(R((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR7escCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSsdS(N((tp((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytfisiRR(R"R<(RR?tf_ident((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt test_simplehs  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSs dddS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?qsiRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_exceptionps  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSsy ddWnnXdS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?ys iRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_caught_exceptionxs  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSsy ddWnnXdS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?‚s iRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_caught_nested_exceptions  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSs dddS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?‹siRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_nested_exceptionŠs  c sŒd„‰‡fd†}tˆƒ}t|ƒ}|j|dd|fdd|fdd|fdd|fdd|fdd|fgƒdS(NcSs dddS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?–scs4yˆ|ƒWnyˆ|ƒWq0q0XnXdS(N((R>(R?(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytg˜siRiRi(R"R<(RRFR@tg_ident((R?s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_exception_in_except_clause•s       c s€d„‰‡fd†}tˆƒ}t|ƒ}|j|dd|fdd|fdd|fdd|fdd|fgƒdS(NcSs dddS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?©scs#zˆ|ƒWd|jdƒXdS(Nsfalling through(R(R>(R?(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRF«siRiRsfalling through(R"R<(RRFR@RG((R?s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_exception_propogation¨s      cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSs"y ddWnddnXdS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?¸s iRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_raise_twice·s  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSsy ddWn ‚nXdS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?Ás iRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_raise_reraiseÀs  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSs tƒ‚dS(N(t Exception(R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?ÊsiRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt test_raiseÉs  cs d„‰‡fd†‰‡fd†‰‡fd†‰‡fd†}tˆƒ}tˆƒ}tˆƒ}tˆƒ}t|ƒ}|j|dd|fdd|fd d|fd d|fd d|fd d |fd d |fd d |fdd |fdd |fg ƒdS( NcSs dddS(Ngð?i((((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?Òscs ˆƒdS(N(((R?(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRFÔscs ˆƒdS(N(((RF(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pythÖscs ˆƒdS(N(((RN(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytiØscs ˆƒdS(N((R>(RO(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytjÚsiRiiiiR(R"R<(RRPR@RGth_identti_identtj_ident((R?RFRNROs4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_distant_exceptionÑs(              c s¤d„‰‡fd†}tˆƒ}t|ƒ}|j|dd|fdd|fdd|fdd|fdd|fdd|fdd|fdd|fgƒdS(Ncss xtdƒD] }|Vq WdS(Ni(trange(RO((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?îscsxˆƒD]}q WdS(N((R>RO(R?(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRFñsiRiR(R"R<(RRFR@RG((R?s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_generatorís         c s¤d„‰‡fd†}tˆƒ}t|ƒ}|j|dd|fdd|fdd|fdd|fdd|fdd|fdd|fdd|fgƒdS(Ncss&xtdƒD] }|Vq Wt‚dS(Ni(RUt StopIteration(RO((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?s csxˆƒD]}q WdS(N((R>RO(R?(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRFsiRiR(R"R<(RRFR@RG((R?s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_stop_iterations         (RRR7RARBRCRDRERHRIRJRKRMRTRVRX(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR=ds        tProfileSimulatorTestCasecBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs t|ƒS(N(R((R((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR7scCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSsdS(N((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?siRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRAs  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSs dddS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?'siRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyttest_basic_exception&s  cCsAd„}t|ƒ}|j|dd|fdd|fgƒdS(NcSsy ddWnnXdS(Ngð?i((R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?/s iRR(R"R<(RR?R@((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRC.s  cs d„‰‡fd†‰‡fd†‰‡fd†‰‡fd†}tˆƒ}tˆƒ}tˆƒ}tˆƒ}t|ƒ}|j|dd|fdd|fd d|fd d|fd d|fd d |fd d |fd d |fdd |fdd |fg ƒdS( NcSs dddS(Ngð?i((((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR?8scs ˆƒdS(N(((R?(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRF:scs ˆƒdS(N(((RF(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRN<scs ˆƒdS(N(((RN(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRO>scs ˆƒdS(N((R>(RO(s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRP@siRiiiiR(R"R<(RRPR@RGRQRRRS((R?RFRNROs4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRT7s(              (RRR7RARZRCRT(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyRYs     cCs4t|dƒr|j}n |j}|j|jfS(Ntf_code(thasattrR[t func_codetco_firstlinenotco_name(tfunctiontcode((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR"Ts  cCsy||ƒWnnXdS(N((R?R>((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pytprotect\scCs„|dkrtƒ}ntjƒ}tjƒz.tj|jƒt||ƒtjdƒWd|rrtj ƒnX|j ƒdd!S(Niiÿÿÿÿ( RRtgct isenabledtdisableRRRRbtenableR'(R:R>told_gc((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyR6cs     cCs#ddl}|jt|ƒƒdS(Niÿÿÿÿ(R8R6(R:R8((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt show_eventsts cCstjtttƒdS(N(Rt run_unittestRR=RY(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyt test_mainyst__main__((RcR8RtunittestttestRtTestCaseRRR(R5R=RYR"Rbt protect_identRR6RhRjR(((s4/usr/local/lib/python2.7/test/test_sys_setprofile.pyts$     #¶: