zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
U
¸ý°d£ã@s„ddlmZddlZddlZddlmZGdd„deƒZGdd„deƒZ    Gd    d
„d
eƒZ
Gd d „d eƒZ d d„Z Gdd„deƒZ dS)é)Úprint_functionNé)ÚTestCasec@s eZdZdS)Ú    SomeErrorN)Ú__name__Ú
__module__Ú __qualname__©r    r    úRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\greenlet/tests/test_tracing.pyrsrc@s2eZdZdZd dd„Zdd„Zdd„Zd    d
„ZdS) ÚGreenletTracerNFcCsg|_||_dS©N)ÚactionsÚerror_on_trace)Úselfrr    r    r
Ú__init__ szGreenletTracer.__init__cGs|j |¡|jrt‚dSr )r Úappendrr©rÚargsr    r    r
Ú__call__s zGreenletTracer.__call__cCst |¡|_|jSr )ÚgreenletÚsettraceÚoldtracer ©rr    r    r
Ú    __enter__s zGreenletTracer.__enter__cGst |j¡dSr )rrrrr    r    r
Ú__exit__szGreenletTracer.__exit__)F©rrrrrrrrr    r    r    r
r
s
 
r c@s(eZdZdZdd„Zdd„Zdd„ZdS)    ÚTestGreenletTracingz*
    Tests of ``greenlet.settrace()``
    c    CsŒt ¡}dd„}dd„}tƒ0}t |¡}| ¡t |¡}| t|j¡W5QRX| |d||ffd||ffd||ffd||ffg¡dS)NcSsdSr r    r    r    r    r
Údummy%sz:TestGreenletTracing.test_a_greenlet_tracing.<locals>.dummycSs
tƒ‚dSr )rr    r    r    r
Údummyexc'sz=TestGreenletTracing.test_a_greenlet_tracing.<locals>.dummyexcÚswitchÚthrow)rÚ
getcurrentr rÚ assertRaisesrÚ assertEqual)rÚmainrrr Úg1Úg2r    r    r
Útest_a_greenlet_tracing#s
 
 
 
 
 
üz+TestGreenletTracing.test_a_greenlet_tracingc    stt ¡‰‡fdd„}t |¡}| ¡tdd$}| t|j¡| t ¡d¡W5QRX| |dˆ|ffg¡dS)Ncs ˆ ¡dSr )rr    ©r$r    r
r9szDTestGreenletTracing.test_b_exception_disables_tracing.<locals>.dummyT)rr)rr!rr r"rr#Úgettrace)rrÚgr r    r(r
Ú!test_b_exception_disables_tracing7s 
 
ÿz5TestGreenletTracing.test_b_exception_disables_tracingc    Cs$tƒ}|t |¡W5QRXdSr )r rr)rÚtracerr    r    r
Útest_set_same_tracer_twiceEsz.TestGreenletTracing.test_set_same_tracer_twiceN)rrrÚ__doc__r'r+r-r    r    r    r
rsrc@s0eZdZdZdd„Zdd„Zdd„Zdd    „ZdS)
Ú PythonTracerNcCs
g|_dSr )r rr    r    r
rRszPythonTracer.__init__cCs|j ||jjf¡dSr )r rÚf_codeÚco_name)rÚframeÚeventÚargr    r    r
rUszPythonTracer.__call__cCst |¡|_|jSr )ÚsysÚ
setprofilerr rr    r    r
rYs zPythonTracer.__enter__cGst |j¡dSr )r5r6rrr    r    r
r]szPythonTracer.__exit__rr    r    r    r
r/Os
r/cCsdS©Né*r    r    r    r    r
Ú tpt_callback`sr9c@sdeZdZdZdZdd„Zdd„Zdd„Zd    d
„Zd d „Z    d d„Z
dd„Z dd„Z dd„Z dd„ZdS)ÚTestPythonTracingzŒ
    Tests of the interaction of ``sys.settrace()``
    with greenlet facilities.
 
    NOTE: Most of this is probably CPython specific.
    Nc    Cs2tƒ }tƒW5QRX| |dddddg¡dS)N©Úreturnr©Úcallr9©r<r9©r>r©Úc_callr)r/r9r#)rr r    r    r
Útest_trace_events_trivialms    ûz+TestPythonTracing.test_trace_events_trivialc    Cstƒ}| ¡W5QRX|Sr )r/r©rZgletr r    r    r
Ú _trace_switch€szTestPythonTracing._trace_switchc Cs,| |¡}| |ddddddddd    g    ¡dS)
Nr;)rBrE)r>Úrunr=r?©r<rF)Zc_returnrEr@rA)rEr#rDr    r    r
Ú$_check_trace_events_func_already_set…s
÷z6TestPythonTracing._check_trace_events_func_already_setcCsdd„}| t |¡¡dS)NcSstƒSr ©r9r    r    r    r
rF”szOTestPythonTracing.test_trace_events_into_greenlet_func_already_set.<locals>.run)rHr©rrFr    r    r
Ú0test_trace_events_into_greenlet_func_already_set“szBTestPythonTracing.test_trace_events_into_greenlet_func_already_setcCs"Gdd„dtjƒ}| |ƒ¡dS)Nc@seZdZdd„ZdS)zQTestPythonTracing.test_trace_events_into_greenlet_subclass_already_set.<locals>.XcSstƒSr rIrr    r    r
rF›szUTestPythonTracing.test_trace_events_into_greenlet_subclass_already_set.<locals>.X.runN©rrrrFr    r    r    r
ÚXšsrM)rrH©rrMr    r    r
Ú4test_trace_events_into_greenlet_subclass_already_set™szFTestPythonTracing.test_trace_events_into_greenlet_subclass_already_setc Cs8| ¡tƒ| ¡| |jddddddddg¡dS)Nr;r=r?rGr@rA)rr9rr#r )rr*r,r    r    r
Ú/_check_trace_events_from_greenlet_sets_profilerŸsøzATestPythonTracing._check_trace_events_from_greenlet_sets_profilercs(tƒ‰‡fdd„}| t |¡ˆ¡dS)Ncsˆ ¡tƒSr ©rr9r    ©r,r    r
rF±szQTestPythonTracing.test_trace_events_from_greenlet_func_sets_profiler.<locals>.run)r/rPrrJr    rRr
Ú2test_trace_events_from_greenlet_func_sets_profiler¯s
  ÿzDTestPythonTracing.test_trace_events_from_greenlet_func_sets_profilercs.tƒ‰G‡fdd„dtjƒ}| |ƒˆ¡dS)NcseZdZ‡fdd„ZdS)zSTestPythonTracing.test_trace_events_from_greenlet_subclass_sets_profiler.<locals>.Xcsˆ ¡tƒSr rQrrRr    r
rF»szWTestPythonTracing.test_trace_events_from_greenlet_subclass_sets_profiler.<locals>.X.runNrLr    rRr    r
rMºsrM)r/rrPrNr    rRr
Ú6test_trace_events_from_greenlet_subclass_sets_profiler¸szHTestPythonTracing.test_trace_events_from_greenlet_subclass_sets_profilerc s|tƒ‰d‰d‰‡‡fdd„}‡‡fdd„}t |¡‰t |¡‰ˆ ¡}| |d¡tƒ| ˆjdddd    d
ddd d g    ¡dS) Ncs ˆ ¡tƒˆ ¡tƒdSr7)rr9rr    ©r&r,r    r
Úg1_runÈs
zPTestPythonTracing.test_trace_events_multiple_greenlets_switching.<locals>.g1_runcs tƒˆ ¡tƒˆ ¡dSr )r9rrr    ©r%r,r    r
Úg2_runÏszPTestPythonTracing.test_trace_events_multiple_greenlets_switching.<locals>.g2_runr8r;r=r?©rBrV)r>rXr@rA©r/rrr#r9r ©rrVrXÚxr    ©r%r&r,r
Ú.test_trace_events_multiple_greenlets_switchingÂs*
 
 ÷z@TestPythonTracing.test_trace_events_multiple_greenlets_switchingc sŠtƒ‰d‰d‰‡‡fdd„}‡‡fdd„}t |¡‰t |¡‰ˆ ¡ˆ ¡ˆ ¡}| |d¡tƒ| ˆjdddd    ddd
d g¡dS) Ncs.t ¡j ¡ˆ ¡tƒˆ ¡tƒdSr7)rr!Úparentrrr9r    rUr    r
rVïs zYTestPythonTracing.test_trace_events_multiple_greenlets_switching_siblings.<locals>.g1_runcs.t ¡j ¡tƒˆ ¡tƒˆ ¡dSr )rr!r_rr9rr    rWr    r
rX÷s
zYTestPythonTracing.test_trace_events_multiple_greenlets_switching_siblings.<locals>.g2_runr8r;r=r?rYr@rArZr[r    r]r
Ú7test_trace_events_multiple_greenlets_switching_siblingsçs,
 
 øzITestPythonTracing.test_trace_events_multiple_greenlets_switching_siblings)rrrr.ZmaxDiffrCrErHrKrOrPrSrTr^r`r    r    r    r
r:cs    
%r:)Ú
__future__rr5rÚrÚ    ExceptionrÚobjectr rr/r9r:r    r    r    r
Ú<module>s  1