a 5dgܸ@sJddlmZddlZddlZddlZddlZddlmZddlZGdddZ GdddZ dd Z d d Z gd e _ d dZgde_ ddZgde_ ddZgde_ ddZgde_ ddZgde_ ddZgde_ ddZd d!Zgd"e_ d#d$Zd%d&Zgd'e_ d(d)Zd*d+Zd,ge_ d-d.Zd/d0Zgd1e_ d2d3Zgd4e_ d5d6Zgd7e_ d8d9Zgd:e_ d;d<Zd=d>Z gd?d@dAgdBd@dCge _ GdDdEdEZ!GdFdGdGej"Z#GdHdIdIe#Z$ej%GdJdKdKe#Z&GdLdMdMej"Z'GdNdOdOZ(dPdQZ)dRdSZ*GdTdUdUej"Z+e,dVkrFe-dS)W)supportNwrapsc@s$eZdZddZddZddZdS) tracecontextcCs||_||_dSNoutputvalueselfrr r 2/usr/local/lib/python3.9/test/test_sys_settrace.py__init__sztracecontext.__init__cCs|j|jdSrrappendr r r r r __enter__sztracecontext.__enter__cGs|j|j dSrrr exc_infor r r __exit__sztracecontext.__exit__N)__name__ __module__ __qualname__rrrr r r r r src@s$eZdZddZddZddZdS)asynctracecontextcCs||_||_dSrrr r r r rszasynctracecontext.__init__cs|j|jdSrrrr r r __aenter__szasynctracecontext.__aenter__cs|j|j dSrrrr r r __aexit__!szasynctracecontext.__aexit__N)rrrrrrr r r r rsrcCs|D] }|VqdSrr )iterablexr r r asynciter$srcCsdSNr r r r r basic+sr!)rcallr liner returncCsd}~d}dSrr rr r r arigo_example0;sr))r"r$r%r%r-r'cCsd}~d}dSrr r(r r r arigo_example1Hsr/cCsd}~d}dSrr r(r r r arigo_example2Usr0)r"r$r*r%r%r4r'cCsd}~d}dSrr r(r r r one_instr_linegsr6)r"r$r*r%r8r'cCs$d}tdD]}|rd}q d}q dSNr r+range)rar r r no_pop_topsrs  r>) r"r$r*r7r%r*r7r1r*)r+r'cCsd}|stqd}dSr)Zbla)yrr r r no_pop_blockssrB)r"r$r*r1r2r'cCsd}dSrr r(r r r calledsrDcCs tdSr)rDr r r r r#sr#)r"r$r#r%rHr'r&cCstdSr Exceptionr r r r raisessrLcCs"z tWntyYn0dSr)rLrKr r r r test_raises  rM) r"r$r*rErGrH exceptionrIr+rOr7r1rCcCst||tj_dSr)syssettrace _getframef_backf_traceZ tracefuncr r r _settrace_and_returns rWcCs t|dSr)rWrVr r r settrace_and_returnsrXr&cCst||tj_tdSr)rQrRrSrTrU RuntimeErrorrVr r r _settrace_and_raises  rZcCs$z t|WntyYn0dSr)rZrYrVr r r settrace_and_raises  r[)rPr7r1rCcCsd}d}||kr|d}ndS)Nr-r r )r=br r r ireturn_examples  r])r"r$r*r7r1r?r@r'cCs<tdd}zd}||}|d7}qWnty6Yn0dS)Nrr8r r< IndexError)itemsir\r r r tightloop_examples   rc) r"r$r*r7r,r,r,r,)r-rOr?r3r5cCs4tdd}zd}||}qWnty.Yn0dS)Nr r2rr_)rarbr r r tighterloop_examples   rd) r"r$r*r7r1r1r1r1)r2rOr,r?r^ccsz dVWn0dS)NTr r r r r generator_functionsrecCs tt}tdD]}|}qdS)N )anyrer<)rrAr r r generator_examples  rh) r"r*ir#r%r%rmr')rmr#rmrO)r%)rpr'r,r?rfr.c@s.eZdZd ddZddZddZdd ZdS) TracerNcCs||_||_g|_dSr)trace_line_eventstrace_opcode_eventsevents)r rrrsr r r r+szTracer.__init__cCs(|jdur|j|_|jdur$|j|_dSr)rr f_trace_linesrsf_trace_opcodes)r framer r r _reconfigure_frame0s  zTracer._reconfigure_framecCs"|||j|j|f|jSrrxrtrf_linenotracer rweventargr r r r{6s z Tracer.tracecCs0||dddD|j|j|f|jS)Ncss|] }|VqdSrr ).0or r r =z)Tracer.traceWithGenexp..r ryr|r r r traceWithGenexp;s zTracer.traceWithGenexp)NN)rrrrrxr{rr r r r rq*s rqc@seZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?S)@ TraceTestCasecCs(t|_t|tjtdSr)gc isenabledusing_gcdisable addCleanuprQrRgettracerr r r setUpFs zTraceTestCase.setUpcCs|jrtdSr)rrenablerr r r tearDownKszTraceTestCase.tearDowncCstSrrqr r r r make_tracerOszTraceTestCase.make_tracerc sNfdd|D}||krJ|ddtdd|Ddd|DdS)Ncsg|]\}}||fqSr r )rle line_offsetr r Urz0TraceTestCase.compare_events..z"events did not match expectation:  cSsg|] }t|qSr strrrr r r rYrcSsg|] }t|qSr rrr r r rZr)failjoindifflibZndiff)r rrtexpected_eventsr rr compare_eventsTs zTraceTestCase.compare_eventscCs<|}t|j|td||jj|j|dSr)rrQrRr{r__code__co_firstlinenort)r funcrttracerr r r run_and_compare\s   zTraceTestCase.run_and_comparecCs|||jdSr)rrtr rr r r run_testdszTraceTestCase.run_testcCs6|}||jtd||jj|j|jdSr)rr{rQrRrrrrt)r rrr r r run_test2gs    zTraceTestCase.run_test2cCstddSrrQrRrr r r test_set_and_retrieve_nonens z(TraceTestCase.test_set_and_retrieve_nonec Cs2dd}t|zWtdn td0dS)NcWsdSrr )argsr r r fnssz4TraceTestCase.test_set_and_retrieve_func..fnr)r rr r r test_set_and_retrieve_funcrs  z(TraceTestCase.test_set_and_retrieve_funccCs|tdSr)rr!rr r r test_01_basic|szTraceTestCase.test_01_basiccCs|tdSr)rr)rr r r test_02_arigo0~szTraceTestCase.test_02_arigo0cCs|tdSr)rr/rr r r test_02_arigo1szTraceTestCase.test_02_arigo1cCs|tdSr)rr0rr r r test_02_arigo2szTraceTestCase.test_02_arigo2cCs|tdSr)rr6rr r r test_03_one_instrszTraceTestCase.test_03_one_instrcCs|tdSr)rrBrr r r test_04_no_pop_blockssz#TraceTestCase.test_04_no_pop_blockscCs|tdSr)rr>rr r r test_05_no_pop_topssz!TraceTestCase.test_05_no_pop_topscCs|tdSr)rr#rr r r test_06_callszTraceTestCase.test_06_callcCs|tdSr)rrMrr r r test_07_raiseszTraceTestCase.test_07_raisecCs|tdSr)rrXrr r r test_08_settrace_and_returnsz)TraceTestCase.test_08_settrace_and_returncCs|tdSr)rr[rr r r test_09_settrace_and_raisesz(TraceTestCase.test_09_settrace_and_raisecCs|tdSr)rr]rr r r test_10_ireturnszTraceTestCase.test_10_ireturncCs|tdSr)rrcrr r r test_11_tightloopszTraceTestCase.test_11_tightloopcCs|tdSr)rrdrr r r test_12_tighterloopsz!TraceTestCase.test_12_tighterloopcCsH|t|}t|jttd|tjj|j tj dSr) rrhrrQrRrrrrrt)r rr r r test_13_genexps    zTraceTestCase.test_13_genexpcCsdd}||gddS)NcSsd}dS)NFrr r(r r r onlinerssz2TraceTestCase.test_14_onliner_if..onliners)r"r$r7r9r)r rr r r test_14_onliner_ifs z TraceTestCase.test_14_onliner_ifcCs4dd}||gddd}||gddS)NcSstdD]}qdSNr+r;r(r r r for_examples z0TraceTestCase.test_15_loops..for_example)r"r$r*r$r*r$r&cSsd}|dkr|d8}qdS)Nr+rr r r(r r r while_examplesz2TraceTestCase.test_15_loops..while_example)r"r*r7r1r7r1r7r9r)r rrr r r test_15_loopss zTraceTestCase.test_15_loopscCs&i}td|||dgddS)Nadef f(): passf)r")r%)rr')execr)r namespacer r r test_16_blank_liness  z!TraceTestCase.test_16_blank_linescCsdd}||ddgdS)NcSsdt_d}dSr)rQrSrU)linenor r r rs z0TraceTestCase.test_17_none_f_trace..funcr"r$rrr r r test_17_none_f_traces z"TraceTestCase.test_17_none_f_tracecCsdd}||gddS)Nc SsTz.func) r"r$r*r7r8rOr1r,)r%) r%)rr'rrr r r test_18_except_with_names z&TraceTestCase.test_18_except_with_namecCsdd}||gddS)NcSs4zz tWd}nd}0Wnty.d}Yn0dS)NrrJ)rAr\r r r rs  z7TraceTestCase.test_19_except_with_finally..func) r"r$r*r7rr,r?r3r5rrr r r test_19_except_with_finallys z)TraceTestCase.test_19_except_with_finallycspGdddfddfdd}|}gd}z||jWntyVYn0|jj|j|dS)Nc@s$eZdZddZddZddZdS)zBTraceTestCase.test_20_async_for_loop..AsyncIteratorWrappercSst||_dSr)iter_it)r objr r r rszKTraceTestCase.test_20_async_for_loop..AsyncIteratorWrapper.__init__cSs|Srr rr r r __aiter__szLTraceTestCase.test_20_async_for_loop..AsyncIteratorWrapper.__aiter__cs(z t|jWSty"tYn0dSr)nextr StopIterationStopAsyncIterationrr r r __anext__s  zLTraceTestCase.test_20_async_for_loop..AsyncIteratorWrapper.__anext__N)rrrrrrr r r r AsyncIteratorWrappersrcs$d2z3dHW}|}q6d}dS)Nabc*r )ZletterrrA)rr r doit_asyncsz8TraceTestCase.test_20_async_for_loop..doit_asyncc s:}z"t||dWtdn td0dSr)rQrRsend)rr)rr r run$s   z1TraceTestCase.test_20_async_for_loop..run)(r"r$)ir#)r%)rr')ir#)r%)rr'rirjrlrnr rOr*r$rirjrlrnrr*r$rirjrlrnrr*r$rirjrlro)rFr%rGrNrIrr7r9)rr{rKrrrrt)r rrrtr )rrr test_20_async_for_loops  )  z$TraceTestCase.test_20_async_for_loopN)#rrrrr staticmethodrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rBs@      rcs(eZdZfddZeddZZS)SkipLineEventsTraceTestCasecs"dd|D}t|||dS)NcSsg|]}|ddkr|qSr$r rrr r r rbrz>SkipLineEventsTraceTestCase.compare_events..)superr)r rrtrZskip_line_events __class__r r rasz*SkipLineEventsTraceTestCase.compare_eventscCs tddS)NF)rrrr r r r resz'SkipLineEventsTraceTestCase.make_tracerrrrrrr __classcell__r r rr r^s rcs(eZdZfddZeddZZS)TraceOpcodesTestCasecsFdd|D}t|dkr2|jt|t|ddt|||dS)NcSsg|]}|ddkr|qS)r Zopcoder rr r r rorz7TraceOpcodesTestCase.compare_events..r z)No 'opcode' events received by the tracer)msg)lenZ assertLessrr)r rrtrZskip_opcode_eventsrr r rns  z#TraceOpcodesTestCase.compare_eventscCs tddS)NT)rsrr r r r rusz TraceOpcodesTestCase.make_tracerrr r rr rjs rc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)RaisingTraceFuncTestCasecCs|tjtdSrrrQrRrrr r r r{szRaisingTraceFuncTestCase.setUpcCs||jkrtn|jSdSr) raiseOnEvent ValueErrorr{r|r r r r{~s zRaisingTraceFuncTestCase.tracecCs |jdkrd}d|}ndSdS)NrOrr )r)r rrAr r r rs  zRaisingTraceFuncTestCase.fc Csx||_zPttdD]:}t|jz |WntyFYq0|dqWnt yr|dYn0dS)Nr zexception not raised!zrecursion counter not reset) rr<rQgetrecursionlimitrRr{rrrrY)r r}rbr r r run_test_for_events    z+RaisingTraceFuncTestCase.run_test_for_eventcCs|ddS)Nr#rrr r r test_callsz"RaisingTraceFuncTestCase.test_callcCs|ddS)Nr%rrr r r test_linesz"RaisingTraceFuncTestCase.test_linecCs|ddS)Nr'rrr r r test_returnsz$RaisingTraceFuncTestCase.test_returncCs|ddSNrOrrr r r test_exceptionsz'RaisingTraceFuncTestCase.test_exceptioncs\ddfddtz Wn"tyLddl}|Yn 0|ddS)NcSstdD] }t|qdS)Nr-)r<print)rbr r r rs z4RaisingTraceFuncTestCase.test_trash_stack..fcs&|dkr"|jjjdkr"tdS)Nr%r+z i am crashing)rzrrrY)rwwhyextrargr r rs z4RaisingTraceFuncTestCase.test_trash_stack..grzexception not propagated)rQrRrYrZcollectr)r rr rr test_trash_stacks   z)RaisingTraceFuncTestCase.test_trash_stackc sfdd}fddt}z6tz |WntyFYn0Wt|n t|0dS)NcSsd}|jdS)Nr)Z no_such_attrr(r r r rsz.fcs"|dkr|\}}}|tSr)ZassertIsInstancerK)rwr}r~typerOr{rr r r rs  z.g)rQrrRAttributeError)r rZexistingr rr test_exception_argumentss   z1RaisingTraceFuncTestCase.test_exception_argumentsN) rrrrr{rrrrrrrrr r r r rzs rc@seZdZdddZddZdS) JumpTracerr%FcCs6|j|_||_||_||_|r"dn|jj|_d|_dS)NF)rcodejumpFromjumpTor}r firstLinedone)r functionrrr} decoratedr r r rs zJumpTracer.__init__cCs|jr dS|jdur4|j|jkr4|dkr4|jd|_||jkr|jr|j|j|jkr|}|durv|j|jkrv|j}qZ|durz|j|j|_Wnt y|j|_Yn0d|_|j S)Nr%r T) rrf_coderrzr}rrTr TypeErrorr{)r rwr}r~rr r r r{s&  zJumpTracer.traceN)r%F)rrrrr{r r r r rs rc CsJz|dWn6tyD}z|dt|vWYd}~n d}~00dS)Nr+Zinteger)rrrrrr r r no_jump_to_non_integerssrc CsVztj}|j|_Wn2tyH}zdt|vr4WYd}~nd}~00tddS)Nr{z'Trace-function-less jump failed to fail)rQrSrTrzrrAssertionError)Zprevious_framerr r r no_jump_without_trace_functions   rc@s:eZdZddZddZddd Zdd d Zdd d ZdddZedddgddZ eddgdddZ eddddgddZ eddgdddZ eddddgd d!Z eddgd"d#d$Zedddgd%d&Zeddgd'd(d)Zedd*dd*gd+d,Zedd-dd-ged.fd/d0Zedd1dd1ged.fd2d3Zedd1ddged4fd5d6Zedddged4fd7d8Zeddddgd9d:Zeddgd;dd?Zeddddgd@dAZeddgdBdCdDZeddgdBdEdFZedddgdGdHZeddgdIdJdKZedddgdLdMZ eddgdNdOdPZ!edd-gdQdRdSZ"eddgdTdUdVZ#eddgdWdXdYZ$eddgdWdZd[Z%eddgd\d]d^Z&eddgd\d_d`Z'eddgdadbdcZ(eddgdadddeZ)eddgdfdgdhZ*eddgdfdidjZ+edkd1gdldmdnZ,eddgdodpdqZ-eddgdodrdsZ.eddgdtdudvZ/eddkgdwdxdyZ0edd-d-dkgdzd{Z1edd-d-dkgd|d}Z2edddged~fddZ3edddgedfddZ4edddgedfddZ5edddgedfddZ6edddgedfddZ7edddgedfddZ8eddgedfddZ9eddgedfddZ:eddddgedfddZ;eddddgedfddZeddgdedfddZ?eddgdedfddZ@eddgedfddZAeddddgedfddZBeddgedfddZCedddgedfddZDedd-dgedfddZEedddgddZFeddgdddZGeddgdddZHeddgedfddZIeddgedfddZJeddgdedfddZKedddgedfddZLed-dgdedfddZMed-dgdedfddZNeddgd¢ddĄZOeddgd¢ddƄZPedd-ddged4fddȄZQed-dddgedfddʄZRed-dddgedfdd̄ZSdd΄ZTddЄZUdd҄ZVddԄZWedddgdedfd׍ddلZXedddgdedfd׍dd݄ZYedddgdedfd׍ddZZeddddgddddZ[dS) JumpTestCasecCs |tjttddSrrrr r r rszJumpTestCase.setUpcCs.||kr*|dt|ddt|dS)NzOutputs don't match: Expected: rz Received: )rrepr)r expectedZreceivedr r r compare_jump_outputsz JumpTestCase.compare_jump_outputNr%Fc Cs~t|||||}t|jg} |dur2|| n2|j||| Wdn1sZ0Ytd||| dSr)rrQrRr{assertRaisesRegexr r rrrrerrorr}r rrr r r r!s   & zJumpTestCase.run_testc Cst|||||}t|jg} |dur8t|| n8|j|t|| Wdn1sf0Ytdtd||| dSr) rrQrRr{asynciorrZset_event_loop_policyrrr r r run_async_test.s  ,  zJumpTestCase.run_async_testcsfdd}|S)Ncs"tfdd}|S)Nc s|jdddSNT)rr}r )rrrr}rrrrr r testAs z7JumpTestCase.jump_test..decorator..testrrrrr}rrrrr decorator@sz)JumpTestCase.jump_test..decoratorr rrrrr}r r rr jump_test<szJumpTestCase.jump_testcsfdd}|S)Ncs"tfdd}|S)Nc s|jdddSr)rrrr r rMs z=JumpTestCase.async_jump_test..decorator..testrrrrr r Lsz/JumpTestCase.async_jump_test..decoratorr r!r rr async_jump_testHszJumpTestCase.async_jump_testr r8cCs"|d|d|ddSNr r+r8rrr r r test_jump_simple_forwardsVs  z&JumpTestCase.test_jump_simple_forwardsr+)r r r+cCs|d|ddSr:r%r&r r r test_jump_simple_backwards\s z'JumpTestCase.test_jump_simple_backwardsr-cCs6dD]"}|ddD]}|dqq|ddS)Nr r+r+r8r2r-r%rrbjr r r test_jump_out_of_block_forwardsas  z,JumpTestCase.test_jump_out_of_block_forwardsr@)r r8r-r r8r-r@r4cCsJ|ddD],}|ddD]}|dq |dq|ddS)Nr rr8)r+r-r@r4r%r+r r r test_jump_out_of_block_backwardsis    z-JumpTestCase.test_jump_out_of_block_backwardsr2csHdD]>}tddg2z 3dHW}|d|dq6|dqdS)Nrr r+r8r2r-rrrrbr r r )test_jump_out_of_async_for_block_forwardsss  z6JumpTestCase.test_jump_out_of_async_for_block_forwards)r+r2r+r2r-r@csPdD]F}|dtdg2z 3dHW}|d|dq6|dqdS)Nrr+r r2r-r@rrr0r r r *test_jump_out_of_async_for_block_backwards{s   z7JumpTestCase.test_jump_out_of_async_for_block_backwardscCs|d|ddS)Nr r8r%r&r r r test_jump_to_codeless_lines z'JumpTestCase.test_jump_to_codeless_line)r r+r8cCs"|d|d|ddSr$r%r&r r r test_jump_to_same_lines  z#JumpTestCase.test_jump_to_same_linercCszH|dW|dz|dW|dn |d0|dn<|dz|dW|dn |d0|d0dS)Nr+r2r@rrr%r&r r r test_jump_in_nested_finallys     z(JumpTestCase.test_jump_in_nested_finallyr4c CsRz,|dddW|d|ddS|d|d0|ddS)Nr+r rr@r4rr%r&r r r test_jump_in_nested_finally_2s     z*JumpTestCase.test_jump_in_nested_finally_2 cCsz|dddW|dz|dW|dn |d0|ddSz|dW|dn |d0|dn<|dz|dW|dn |d0|d0|ddS) Nr+r rr@rrfr9 r%r&r r r test_jump_in_nested_finally_3s*        z*JumpTestCase.test_jump_in_nested_finally_3Z unreachablec CszL|dW|d|ddSz|dW|dq|d0nH|d|dYdSz|dW|dn |d00|ddS)Nr+r2r-rrfr:r%r&r r r 5test_no_jump_over_return_try_finally_in_finally_blocks"        zBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_blockcCs$|d|dq |ddS)Nr r8r2r%r&r r r test_no_jump_infinite_while_loops  z-JumpTestCase.test_no_jump_infinite_while_loopcCs.d}|d|dkr*|d|d7}qdS)Nr r+r2r%r0r r r #test_jump_forwards_into_while_blocks   z0JumpTestCase.test_jump_forwards_into_while_block)r8r8r8r-cCs.d}|dkr |d|d7}q|ddS)Nr r+r8r-r%r0r r r $test_jump_backwards_into_while_blocks   z1JumpTestCase.test_jump_backwards_into_while_blockcCsBt|d|dWdn1s*0Y|ddSr$rrr&r r r $test_jump_forwards_out_of_with_blocks (z1JumpTestCase.test_jump_forwards_out_of_with_blockc sVt|d4IdH |dWdIdHqH1IdHs>0Y|ddSr$rrr&r r r *test_jump_forwards_out_of_async_with_blocks4z7JumpTestCase.test_jump_forwards_out_of_async_with_block)r r+r r+r8rHcCsB|dt|d|dWdn1s40YdSr$rrr&r r r %test_jump_backwards_out_of_with_blocks  z2JumpTestCase.test_jump_backwards_out_of_with_blockc sV|dt|d4IdH |dWdIdHqR1IdHsH0YdSr$rrr&r r r +test_jump_backwards_out_of_async_with_blocks z8JumpTestCase.test_jump_backwards_out_of_async_with_blockc Cs4z|dW|dn |d0|ddSNr+r2r-r%r&r r r +test_jump_forwards_out_of_try_finally_blocks z8JumpTestCase.test_jump_forwards_out_of_try_finally_block)r r r8r-c Cs4|dz|dW|dn |d0dSNr r8r-r%r&r r r ,test_jump_backwards_out_of_try_finally_blocks  z9JumpTestCase.test_jump_backwards_out_of_try_finally_blockcCs6z|dWn|dYn0|ddSNr+r2r@r%r&r r r *test_jump_forwards_out_of_try_except_blocks  z7JumpTestCase.test_jump_forwards_out_of_try_except_block)r r r8cCs6|dz|dWn|dYn0dSrJr%r&r r r +test_jump_backwards_out_of_try_except_blocks   z8JumpTestCase.test_jump_backwards_out_of_try_except_block)r2r4rcCs\z ddWn@ty2|d|dYntyL|dYn0|ddSNr rr2r-r4rZeroDivisionErrorrFloatingPointErrorr&r r r test_jump_between_except_blockss    z,JumpTestCase.test_jump_between_except_blocks)r2r@r4cCsFz ddWn*|d|d|dYn0|ddS)Nr rr2r-r@r4r%r&r r r test_jump_within_except_block"s   z*JumpTestCase.test_jump_within_except_block)r r2r-rmcCsv|dt|d|dWdn1s40Yt|d|dWdn1sh0YdSNr r+r8r2r-rDr&r r r test_jump_across_with,s   ( z"JumpTestCase.test_jump_across_withc s|dt|d4IdH |dWdIdHqR1IdHsH0Yt|d4IdH |dWdIdHq1IdHs0YdSrUrFr&r r r test_jump_across_async_with4s  4z(JumpTestCase.test_jump_across_async_with)r r8r-r@c Cs`|ddD]B}t|d|dWdn1s<0Y|dq|ddSNr rr8r2r-r@rDr0r r r ,test_jump_out_of_with_block_within_for_block<s   ( z9JumpTestCase.test_jump_out_of_with_block_within_for_blockc st|ddD]V}t|d4IdH |dWdIdHqZ1IdHsP0Y|dq|ddSrXrFr0r r r 2test_jump_out_of_async_with_block_within_for_blockEs  4 z?JumpTestCase.test_jump_out_of_async_with_block_within_for_block)r r+r8r-rHr@c Cs|dt|dNt|d|dWdn1s@0Y|dWdn1sh0Y|ddSNr r+r8r2r-r@rDr&r r r -test_jump_out_of_with_block_within_with_blockNs    ((z:JumpTestCase.test_jump_out_of_with_block_within_with_blockc s|dt|dbt|d4IdH |dWdIdHq^1IdHsT0Y|dWdn1s|0Y|ddSr[)rrrr&r r r 3test_jump_out_of_async_with_block_within_with_blockWs   4(z@JumpTestCase.test_jump_out_of_async_with_block_within_with_block)r+r2r@r4cCszL|dWt|d|dWdn1s80Y|dn@t|d|dWdn1sx0Y|d0|ddSNr+r2r-r@r4rDr&r r r 0test_jump_out_of_with_block_within_finally_block`s  ( ( z=JumpTestCase.test_jump_out_of_with_block_within_finally_blockcsz`|dWt|d4IdH |dWdIdHqV1IdHsL0Y|dnTt|d4IdH |dWdIdHq1IdHs0Y|d0|ddSr^rFr&r r r 6test_jump_out_of_async_with_block_within_finally_blockjs 4 4 zCJumpTestCase.test_jump_out_of_async_with_block_within_finally_blockr)r r8r-r9r:c Csz|ddD]\}|ddD]>}|dz"dD]}|dq4W|dq |d0q |dq|d dS) Nr rr8r)r-rrfr9r:r%)rrbr,kr r r &test_jump_out_of_complex_nested_blocksts    z3JumpTestCase.test_jump_out_of_complex_nested_blocks)r r+r-cCsL|dt|d}|dWdn1s40Y|ddSNr r+r2r-rDrrr r r test_jump_out_of_with_assignments   (z-JumpTestCase.test_jump_out_of_with_assignmentc s`|dt|d4IdH }|dWdIdHqR1IdHsH0Y|ddSrcrFrdr r r &test_jump_out_of_async_with_assignments  4z3JumpTestCase.test_jump_out_of_async_with_assignment)r r@rrc Cs\|dz6|d|s*W|ddS|dW|dn |d0|ddS)Nr r8rr@rr%r&r r r *test_jump_over_return_in_try_finally_blocks    z7JumpTestCase.test_jump_over_return_in_try_finally_block)r r8rrfr9 c Csr|d|dz4|d|s2W|dqd|dW|dn |d0|dqdq |ddS)Nr r8r-rfrr9rhr%r&r r r )test_jump_over_break_in_try_finally_blocks      z6JumpTestCase.test_jump_over_break_in_try_finally_blockcCsF|d|s$dD]}|dqn|d|d|ddSNr r*r2r@r4rr%r0r r r $test_jump_over_for_block_before_elses   z1JumpTestCase.test_jump_over_for_block_before_elsecsV|d|s4tdg2z3dHW}|dq6n|d|d|ddSNr r8r2r@r4rr2r0r r r *test_jump_over_async_for_block_before_elses   z7JumpTestCase.test_jump_over_async_for_block_before_elseZaftercCs|d|ddSr:r%r&r r r test_no_jump_too_far_forwardss z*JumpTestCase.test_no_jump_too_far_forwardsrHbeforecCs|d|ddSr:r%r&r r r test_no_jump_too_far_backwardss z+JumpTestCase.test_no_jump_too_far_backwardsexceptcCs,z|dWn|dYn0dSNr+r2r%r&r r r test_no_jump_to_except_1s  z%JumpTestCase.test_no_jump_to_except_1cCs2z|dWnty,|dYn0dSrrrrr&r r r test_no_jump_to_except_2s   z%JumpTestCase.test_no_jump_to_except_2c CsFz|dWn2ty@}z|d|WYd}~n d}~00dSrrrtr r r r test_no_jump_to_except_3s  z%JumpTestCase.test_no_jump_to_except_3c CsJz|dWn6ttfyD}z|d|WYd}~n d}~00dSrr)rrrYr r r r test_no_jump_to_except_4s  z%JumpTestCase.test_no_jump_to_except_4ZintocCs"|ddD]}|dqdS)Nr r)r8r%r0r r r $test_no_jump_forwards_into_for_blocks z1JumpTestCase.test_no_jump_forwards_into_for_blockcs4|dtddg2z3dHW}|dq6dSr$r2r0r r r *test_no_jump_forwards_into_async_for_blocks z7JumpTestCase.test_no_jump_forwards_into_async_for_blockcCs"dD]}|dq|ddS)Nr)r+r8r%r0r r r %test_no_jump_backwards_into_for_blocks z2JumpTestCase.test_no_jump_backwards_into_for_blockcs4tddg2z3dHW}|dq 6|ddSr$r/r0r r r +test_no_jump_backwards_into_async_for_blocksz8JumpTestCase.test_no_jump_backwards_into_async_for_blockcCsB|dt|d|dWdn1s40YdSr$rDr&r r r %test_no_jump_forwards_into_with_block s  z2JumpTestCase.test_no_jump_forwards_into_with_blockc sV|dt|d4IdH |dWdIdHqR1IdHsH0YdSr$rFr&r r r +test_no_jump_forwards_into_async_with_blocks z8JumpTestCase.test_no_jump_forwards_into_async_with_block)r r+rpcCsBt|d|dWdn1s*0Y|ddSr$r@r&r r r &test_no_jump_backwards_into_with_blocks (z3JumpTestCase.test_no_jump_backwards_into_with_blockc sVt|d4IdH |dWdIdHqH1IdHs>0Y|ddSr$rBr&r r r ,test_no_jump_backwards_into_async_with_blocks4z9JumpTestCase.test_no_jump_backwards_into_async_with_blockc Cs4|dz|dW|dn |d0dSrJr%r&r r r ,test_no_jump_forwards_into_try_finally_block"s  z9JumpTestCase.test_no_jump_forwards_into_try_finally_blockc Cs4z|dW|dn |d0|ddSrHr%r&r r r -test_no_jump_backwards_into_try_finally_block*s z:JumpTestCase.test_no_jump_backwards_into_try_finally_blockcCs6|dz|dWn|dYn0dSrJr%r&r r r +test_no_jump_forwards_into_try_except_block2s   z8JumpTestCase.test_no_jump_forwards_into_try_except_blockcCs6z|dWn|dYn0|ddSrLr%r&r r r ,test_no_jump_backwards_into_try_except_block;s  z9JumpTestCase.test_no_jump_backwards_into_try_except_blockc Csnz ddWnRty2|d|dYn.ty^}z|dWYd}~n d}~00|ddSrOrPr r r r $test_no_jump_between_except_blocks_2Es    z1JumpTestCase.test_no_jump_between_except_blocks_2c Cs4|dz|dW|dn |d0dSrJr%r&r r r test_jump_into_finally_blockPs  z)JumpTestCase.test_jump_into_finally_block)r+r@r4c CsRz,|d|dW|d|dn|d|d0|ddS)Nr+r8r-r@r4r%r&r r r +test_jump_into_finally_block_from_try_blockXs     z8JumpTestCase.test_jump_into_finally_block_from_try_block)r r8r r8r-c Cs4|dz|dW|dn |d0dSrJr%r&r r r test_jump_out_of_finally_blockbs  z+JumpTestCase.test_jump_out_of_finally_blockzinto an 'except'cCs4|dz|dWn|dYn0dSrJr%r&r r r #test_no_jump_into_bare_except_blockjs  z0JumpTestCase.test_no_jump_into_bare_except_blockcCs:|dz|dWnty4|dYn0dSrJrrKr&r r r (test_no_jump_into_qualified_except_blockrs   z5JumpTestCase.test_no_jump_into_qualified_except_block)r+r-r@cCsJz|d|dWn"|d|dYn0|ddSNr+r8r-r@rr%r&r r r 2test_no_jump_into_bare_except_block_from_try_blockzs   z?JumpTestCase.test_no_jump_into_bare_except_block_from_try_blockcCsPz|d|dWn(ty@|d|dYn0|ddSr)rrQr&r r r 7test_no_jump_into_qualified_except_block_from_try_blocks    zDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block)r r8r@zout of an 'except'cCsF|dz|dddWn |d|dYn0dSNr r8rr@r4r%r&r r r %test_no_jump_out_of_bare_except_blocks    z2JumpTestCase.test_no_jump_out_of_bare_except_blockcCsL|dz|dddWn&tyF|d|dYn0dSrrr&r r r *test_no_jump_out_of_qualified_except_blocks     z7JumpTestCase.test_no_jump_out_of_qualified_except_block)r r+r-rHcCsv|dt|d|dWdn1s40Yt|d|dWdn1sh0YdSrUrDr&r r r test_jump_between_with_blockss   ( z*JumpTestCase.test_jump_between_with_blocksc s|dt|d4IdH |dWdIdHqR1IdHsH0Yt|d4IdH |dWdIdHq1IdHs0YdSrUrFr&r r r #test_jump_between_async_with_blockss  4z0JumpTestCase.test_jump_between_async_with_blocksc CsVz$|dW|d|ddS|d|dYdS0|ddS)Nr+r2r-r4r%r&r r r -test_no_jump_over_return_out_of_finally_blocks     z:JumpTestCase.test_no_jump_over_return_out_of_finally_blockcCsF|d|s$dD]}|dqn|d|d|ddSrjr%r0r r r 'test_no_jump_into_for_block_before_elses   z4JumpTestCase.test_no_jump_into_for_block_before_elsecsV|d|s4tdg2z3dHW}|dq6n|d|d|ddSrlr2r0r r r -test_no_jump_into_async_for_block_before_elses   z:JumpTestCase.test_no_jump_into_async_for_block_before_elsecCs|tdddgdS)Nr+ZSpamT)rrrr r r test_no_jump_to_non_integerssz)JumpTestCase.test_no_jump_to_non_integerscCs tdSr)rrr r r #test_no_jump_without_trace_functionsz0JumpTestCase.test_no_jump_without_trace_functioncCs0i}tdd||d}||dddgdS)Nadef f(output): # line 0 x = 0 # line 1 y = 1 # line 2 ''' # line 3 %s # lines 4-1004 ''' # line 1005 x += 1 # line 1006 output.append(x) # line 1007 return)a rr+ir)rr)r drr r r test_large_functions z JumpTestCase.test_large_functioncsjtdddGfddd}t|dd}t|jdgi}t|td|gd |ddS) Nzd # Comments don't count. output.append(2) # firstlineno is here. output.append(3) output.append(4) z rcseZdZZdS)z.fake_functionN)rrrrr rr r fake_functionsrr+rr)r+r8r+r8r2)compilerrQrRr{rr)r rrrr rr test_jump_to_firstlinenos    z%JumpTestCase.test_jump_to_firstlinenor#z5can't jump from the 'call' trace event of a new frame)r}rcs*dfdd}|ddS)Nr csddS)Nr8r%r r&r r nestedsz3JumpTestCase.test_no_jump_from_call..nestedr-r%)rrr r&r test_no_jump_from_calls  z#JumpTestCase.test_no_jump_from_callr'z'can only jump from a 'line' trace eventcCs|ddSrr%r&r r r test_no_jump_from_return_events z+JumpTestCase.test_no_jump_from_return_eventrOcCs|ddddS)Nr rr%r&r r r !test_no_jump_from_exception_event s z.JumpTestCase.test_no_jump_from_exception_event)r}cs$fdd}t|ddS)Nc3sddVdS)Nr+r8r%r r&r r gens z.JumpTestCase.test_jump_from_yield..genr-)rr)rrr r&r test_jump_from_yields  z!JumpTestCase.test_jump_from_yield)Nr%F)Nr%F)Nr%)Nr%)\rrrrrrrr"r#r'r(r-r.r1r3r4r5r6rQr8r;rr<r=r>r?rArCrErGrIrKrMrNrSrTrVrWrYrZr\r]r_r`rbrerfrgrirkrmrnrprsrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rsX                                                                                   r__main__).rrZunittestrQrr functoolsrrrrrr!rtr)r/r0r6r>rBrDr#rLrMrWrXrZr[r]rcrdrerhrqZTestCaserrZ cpython_onlyrrrrrrrmainr r r r s                    `&