zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
U
¸ý°ds“ã@sôddlmZddlmZddlmZddlZddlZddlZddlZddlm    Z    m
Z
ddl m Z ddl m Z dd    lmZGd
d „d eƒZd d „Zdd„ZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZedkrðddlZe ¡dS)é)Úabsolute_import)Údivision)Úprint_functionN)ÚABCMetaÚabstractmethod)Úgreenleté)ÚTestCase)Úfails_leakcheckc@s eZdZdS)Ú    SomeErrorN©Ú__name__Ú
__module__Ú __qualname__©rrúSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\greenlet/tests/test_greenlet.pyr sr cCs<zt ¡j ¡Wn | t ¡d¡‚YnXt‚dS©Nr)rÚ
getcurrentÚparentÚswitchÚappendÚsysÚexc_infor ©ÚseenrrrÚfmains rcCs"dd„}t||d}| |¡dS)NcSs|‚dS©Nr)ÚexcrrrÚcrasher%szsend_exception.<locals>.crasher©r©rr)ÚgrrÚg1rrrÚsend_exception"s r#c@sbeZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„ZedUd6d7„ƒZed8d9„ƒZd:d;„Z ed<d=„ƒZ!d>d?„Z"d@dA„Z#dBdC„Z$dDdE„Z%dFdG„Z&dHdI„Z'dJdK„Z(dLdM„Z)dNdO„Z*dPdQ„Z+dRdS„Z,dTS)VÚ TestGreenletcs^g‰‡fdd„}t|ƒ}ˆ d¡| ¡ˆ d¡| ¡ˆ d¡| ˆttdƒƒ¡dS)Ncs&ˆ d¡t ¡j ¡ˆ d¡dS)Nré©rrrrrr©ÚlstrrÚf0s
z'TestGreenlet._do_simple_test.<locals>.frééé)rrrÚ assertEqualÚlistÚrange)Úselfr)r!rr'rÚ_do_simple_test-s 
 
 
zTestGreenlet._do_simple_testcCs | ¡dSr)r1©r0rrrÚ test_simple<szTestGreenlet.test_simplec    Cs:tƒ}| t¡}| ¡W5QRX| dt|jƒ¡dS©NÚrun)rÚ assertRaisesÚAttributeErrorrÚassertInÚstrÚ    exception©r0r!rrrrÚ(test_switch_no_run_raises_AttributeError?s z5TestGreenlet.test_switch_no_run_raises_AttributeErrorc    Cs<tƒ}| t¡}| t¡W5QRX| dt|jƒ¡dSr4)rr6r7Úthrowr r8r9r:r;rrrÚ'test_throw_no_run_raises_AttributeErrorFs z4TestGreenlet.test_throw_no_run_raises_AttributeErrorcCs*tdd}| |¡| |jt ¡¡dS)Nr)rÚassertIsNotNoneÚassertIsrr©r0r!rrrÚtest_parent_equals_NoneMs
 
z$TestGreenlet.test_parent_equals_NonecCs$tdd}| |¡| |j¡dS)N)r5)rr?Ú assertIsNoner5rArrrÚtest_run_equals_NoneRs
 
z!TestGreenlet.test_run_equals_Nonecs g‰‡fdd„}t|ƒ}t|ƒ}| ¡| tˆƒd¡| ¡| tˆƒd¡| ¡| tˆƒd¡| |jd¡| ¡| tˆƒd¡| |jd¡dS)Ncs*ˆ d¡t ¡j ¡ˆ ddg¡dS)Nr)rrrrrÚextendrr'rrr)Zs
z)TestGreenlet.test_two_children.<locals>.frr*r+Té)rrr-ÚlenÚdead)r0r)r!Úhrr'rÚtest_two_childrenWs zTestGreenlet.test_two_childrencshg‰‡fdd„‰‡‡fdd„}t|ƒ}| t |¡d¡| ¡| ˆdddg¡| t |¡d¡dS)    Ncsˆ d¡t ¡j ¡dS)NÚbr&rr'rrr)ns
z3TestGreenlet.test_two_recursive_children.<locals>.fcs(ˆ d¡tˆƒ}| ¡ˆ d¡dS)NÚaÚc)rrr©r!©r)r(rrr!rs
z3TestGreenlet.test_two_recursive_children.<locals>.gr*rLrKrM)rr-rÚ getrefcountrrArrOrÚtest_two_recursive_childrenks z(TestGreenlet.test_two_recursive_childrencsfg‰‡‡fdd„‰‡fdd„tdƒDƒ}|D] }| ¡q,|D]}| d¡q>ˆ tˆƒt|ƒ¡dS)Ncsˆ ¡ˆ d¡dS©NT)r1rr)r0Úsuccessrrr)‚sz$TestGreenlet.test_threads.<locals>.fcsg|]}tjˆd‘qS)©Útarget)Ú    threadingÚThread)Ú.0Úi©r)rrÚ
<listcomp>…sz-TestGreenlet.test_threads.<locals>.<listcomp>é
)r/ÚstartÚjoinr-rG)r0ZthsÚthr)r)r0rSrÚ test_threadss
 zTestGreenlet.test_threadscCs g}ttƒ}ttƒ}| |¡| |¡||_| |g¡| t|j¡| |tg¡| ¡}| |d¡| |tg¡| d¡}| |d¡| |tg¡dS)Nré)rrrrr-r6r )r0rr"Úg2ÚvaluerrrÚtest_exceptionŒs
 
 
 zTestGreenlet.test_exceptioncCs8g}ttƒ}| |¡| tt|t¡| |tg¡dSr)rrrr6ÚKeyErrorr#r-)r0rr"rrrÚtest_send_exception¨s
 
z TestGreenlet.test_send_exceptioncCspg}ttƒ}ttƒ}| |¡| |¡| |g¡~t ¡| |tjg¡~t ¡| |tjtjg¡dSr)rrrr-ÚgcÚcollectÚ GreenletExit)r0rr"rbrrrÚ test_dealloc¯s
 
 zTestGreenlet.test_dealloccCsœdd„}t|ƒ}| ¡tj}zddlm}Wn tk
rNddlm}YnX|ƒ}t_z~W5|t_X| ¡}|     d|¡|     d|¡|     d|¡dS)NcSs2zt ¡j ¡Wntjk
r,t‚YnXdSr)rrrrrir rrrrr5¾szHTestGreenlet.test_dealloc_catches_GreenletExit_throws_other.<locals>.runr)ÚStringIOÚ    ExceptionZignoredr )
rrrÚstderrÚ    cStringIOrkÚ ImportErrorÚioÚgetvaluer8)r0r5r!Z    oldstderrrkrmÚvrrrÚ.test_dealloc_catches_GreenletExit_throws_other½s    z;TestGreenlet.test_dealloc_catches_GreenletExit_throws_otherc    sêg‰g‰t ¡‰t ¡‰t ¡‰t ¡‰‡‡‡‡‡‡fdd„}tj|d}| ¡ˆ d¡| ˆg¡| tˆƒd¡ˆdd…=t ¡| ˆg¡ˆ     ¡ˆ d¡z| ˆt j g¡W5ˆ     ¡| 
d¡ˆdd…=ˆdd…=XdS)NcsZttƒ}| ˆ¡ˆ |¡~t ¡ˆ ¡ˆ d¡tƒˆ ¡ˆ d¡tƒdS)Nr%)rrrrrgrhÚsetÚwait)r"©Z/bg_glet_created_running_and_no_longer_ref_in_bgZbg_should_be_clearZfg_ref_releasedZok_to_exit_bg_threadrZsomerefrrr)äs
 
 
 
z1TestGreenlet.test_dealloc_other_thread.<locals>.frTr\rr%) rVÚEventrWr]rur-rGrgrhrtr^rri)r0r)ÚtrrvrÚtest_dealloc_other_threadÛs. 
 
 
 
 
z&TestGreenlet.test_dealloc_other_threadcsf‡fdd„}t|ƒ}| ¡}ˆ ||jk¡ˆ |¡| ¡}ˆ |¡ˆ |d¡ˆ |jd¡dS)Ncs,t d¡}ˆ |jd¡t ¡j |¡dS)Nrúmeaning of life)rÚ    _getframer-Úf_backrrrrrZr2rrÚf1s
z#TestGreenlet.test_frame.<locals>.f1rz)rrÚ
assertTrueÚgr_frameÚ assertFalser-)r0r}r!ÚframeZfrom_grr2rÚ
test_frames 
 
 zTestGreenlet.test_framecCsLdd„}tj|dd}tj|dd}| ¡| ¡| d¡| d¡dS)Ncst‡fdd„ƒ}| ¡dS)Ncs
t ˆ¡Sr)ÚtimeÚsleepr©ÚxrrÚ<lambda>óz>TestGreenlet.test_thread_bug.<locals>.runner.<locals>.<lambda>r )r†r!rr…rÚrunnersz,TestGreenlet.test_thread_bug.<locals>.runner)gš™™™™™É?©rUÚargs)g333333Ó?r\)rVrWr]r^)r0r‰Út1Út2rrrÚtest_thread_bugs
zTestGreenlet.test_thread_bugcs.‡fdd„}t|ƒjddd}ˆ |d¡dS)Ncsˆ |d¡ˆ |d¡dS)Nr+r*é*)r-©rLrKr2rrr5#s  z,TestGreenlet.test_switch_kwargs.<locals>.runr+r*rr©rrr-)r0r5r†rr2rÚtest_switch_kwargs"s zTestGreenlet.test_switch_kwargscCsRdd„}t|ƒ}| ddi| d¡¡| dddif| ¡¡| d| ¡¡dS)NcSs2t ¡jj|dt ¡jjddd||dfS)Nr…r*r%©rrrrr…rrrr5+sz6TestGreenlet.test_switch_kwargs_to_parent.<locals>.runr†r%)r*)r%é    )rr-r)r0r5r!rrrÚtest_switch_kwargs_to_parent*s
z)TestGreenlet.test_switch_kwargs_to_parentc    s„i‰t ¡‰t ¡‰‡‡‡fdd„}tj|d}| ¡ˆ d¡| tj¡ˆd ¡W5QRXˆ     ¡| 
d¡ˆ  ¡dS)Ncs&tdd„ƒˆd<ˆ ¡ˆ d¡dS)NcSsdSrrrrrrr‡:rˆzITestGreenlet.test_switch_to_another_thread.<locals>.run.<locals>.<lambda>r!r\©rrtrur©Z created_eventÚdataÚ
done_eventrrr59sz7TestGreenlet.test_switch_to_another_thread.<locals>.runrTr\r!) rVrwrWr]rur6rÚerrorrrtr^Úclear)r0r5Úthreadrr—rÚtest_switch_to_another_thread4s 
 
z*TestGreenlet.test_switch_to_another_threadcs*‡‡fdd„}‡fdd„‰t|ƒ ¡dS)NcsBz tdƒ‚Wn0t ¡}tˆƒ ¡ˆ |t ¡¡YnXdS)NZfun)Ú
ValueErrorrrrrr-)r©rIr0rrr)Hs   z&TestGreenlet.test_exc_state.<locals>.fcsˆ t ¡d¡dS)N)NNN)r-rrrr2rrrIPsz&TestGreenlet.test_exc_state.<locals>.hr )r0r)rrŸrÚtest_exc_stateGs zTestGreenlet.test_exc_statecCs’dd„}dd„}dd„}t|ƒ}| |ji¡| ¡| |jd¡| |jddi¡|j|_| |jddi¡| t||¡| t||d¡dS)    NcSsdt ¡_dS©Nr)rrÚtestrrrrr)Vsz*TestGreenlet.test_instance_dict.<locals>.fcSs|`dSr©Ú__dict__rNrrrÚdeldictXsz0TestGreenlet.test_instance_dict.<locals>.deldictcSs
||_dSrr£)r!rcrrrÚsetdictZsz0TestGreenlet.test_instance_dict.<locals>.setdictrr¢)rr-r¤rr¢r6Ú    TypeError)r0r)r¥r¦r!rrrÚtest_instance_dictUszTestGreenlet.test_instance_dictcs2g‰‡fdd„}t|ƒ}| ¡| ˆdg¡dS)Ncsˆ tt ¡dƒ¡dSr4)rÚhasattrrrr©Zhas_runrrÚfunchs ÿz;TestGreenlet.test_running_greenlet_has_no_run.<locals>.funcFr‘)r0r«r!rrªrÚ test_running_greenlet_has_no_runfs
 z-TestGreenlet.test_running_greenlet_has_no_runcCs0ddl}| t|jtƒ¡| t|jtƒ¡dSr)Úcopyr6r§rÚdeepcopy)r0r­rrrÚ test_deepcopyqszTestGreenlet.test_deepcopycs€tdd„ƒ‰t ¡‰g‰‡‡‡fdd„}t|ˆd}| ¡~| ˆ¡| ˆdˆ¡| ˆdjˆ¡ˆdd…=d‰d‰dS)NcSsdSrrrrrrr‡wrˆz;TestGreenlet.test_parent_restored_on_kill.<locals>.<lambda>csNz ˆ ¡Wn<tjk
rHˆ t ¡j¡ˆ t ¡¡ˆ ¡YnXdSr)rrrirrrr©ZhubÚmainÚresultrrÚworkerzs  z9TestGreenlet.test_parent_restored_on_kill.<locals>.workerrrr)rrrr~r@r)r0r³r!rr°rÚtest_parent_restored_on_killvs      
 
z)TestGreenlet.test_parent_restored_on_killc    Cs8tƒ}tdd„|d}| t¡| ¡W5QRXdS)NcSsdSrrrrrrr‡•rˆz9TestGreenlet.test_parent_return_failure.<locals>.<lambda>r)rr6r7r)r0r"rbrrrÚtest_parent_return_failure‘s z'TestGreenlet.test_parent_return_failurecCs2Gdd„dtƒ}|dd„ƒ}| t|jtƒ¡dS)Nc@seZdZdd„ZdS)z>TestGreenlet.test_throw_exception_not_lost.<locals>.mygreenletcSs$z
tƒ‚Wn YnXt ||¡Sr)rlrÚ__getattribute__©r0Únamerrrr¶œs
 
zOTestGreenlet.test_throw_exception_not_lost.<locals>.mygreenlet.__getattribute__N©r rrr¶rrrrÚ
mygreenlet›srºcSsdSrrrrrrr‡¢rˆz<TestGreenlet.test_throw_exception_not_lost.<locals>.<lambda>)rr6r r=)r0rºr!rrrÚtest_throw_exception_not_lostšs z*TestGreenlet.test_throw_exception_not_lostFc    sg‰dd„‰‡‡‡fdd„}tj|d}| ¡| d¡~ˆrH| ¡| tj¡}ˆd t    ¡W5QRXˆsŠ| 
t |j ƒdd    g¡n|  t |j ƒd¡tˆdjd
ƒrÐ| t¡ˆdj ¡W5QRXˆsæˆdjj ¡n| ˆdj¡~d‰ˆdd…=d |_dS) NcSst ¡j ¡dSrr“rrrrr³¨szGTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.workercs2tˆƒ}| ¡ˆ |¡ˆr.| ¡t ¡dSr)rrrrrN©r²Úwait_for_cleanupr³rrÚcreator«s 
zHTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.creatorrTr\rúBcannot switch to a different thread (which happens to have exited)ú#cannot switch to a different threadr›T)rVrWr]r^Úwait_for_pending_cleanupsr6rršr=r r8r9r:r-r©rÚ RuntimeErrorr›Úf_localsrCÚexpect_greenlet_leak)r0r½r¾rxrrr¼rÚ*_do_test_throw_to_dead_thread_doesnt_crash¥s@ 
þÿþ 
z7TestGreenlet._do_test_throw_to_dead_thread_doesnt_crashcCs | ¡dSr©rÅr2rrrÚ&test_throw_to_dead_thread_doesnt_crashÞsz3TestGreenlet.test_throw_to_dead_thread_doesnt_crashcCs| d¡dSrRrÆr2rrrÚ+test_throw_to_dead_thread_doesnt_crash_waitâsz8TestGreenlet.test_throw_to_dead_thread_doesnt_crash_waitcCs2Gdd„dtƒ}|ƒ}| | d¡d¡d|_dS)Nc@s$eZdZdd„Zdd„Zdd„ZdS)z7TestGreenlet.test_recursive_startup.<locals>.convolutedcSst |¡d|_dSr)rÚ__init__Úcountr2rrrrÉès
z@TestGreenlet.test_recursive_startup.<locals>.convoluted.__init__cSs.|dkr"|jdkr"d|_| d¡t ||¡S)Nr5rré+)rÊrrr¶r·rrrr¶ës
zHTestGreenlet.test_recursive_startup.<locals>.convoluted.__getattribute__cSs|j |¡qdSr©rr©r0rcrrrr5ðsz;TestGreenlet.test_recursive_startup.<locals>.convoluted.runN)r rrrÉr¶r5rrrrÚ
convolutedçsrÎrrËT)rr-rrÄ)r0rÎr!rrrÚtest_recursive_startupås z#TestGreenlet.test_recursive_startupcsºt ¡‰ˆ ¡t ¡‰ˆ ¡G‡‡fdd„dtƒ}dd„}‡‡‡fdd„}t ¡}t|ƒg‰|ƒˆd_ˆd ¡tj|d}|     ¡ˆ 
¡ˆ ¡|  t ¡|¡|  d    ¡dS)
NcseZdZ‡‡fdd„ZdS)z;TestGreenlet.test_threaded_updatecurrent.<locals>.finalizedcsˆ ¡ˆ ¡dSr©ÚreleaseÚacquirer2©Úlock1Úlock2rrÚ__del__szCTestGreenlet.test_threaded_updatecurrent.<locals>.finalized.__del__N©r rrrÖrrÓrrÚ    finalizedsrØcSst ¡j ¡dSrr“rrrrÚ deallocator
sz=TestGreenlet.test_threaded_updatecurrent.<locals>.deallocatorcs:ˆ ¡t ¡ˆd=ˆ ¡ˆ ¡t ¡ˆ ¡dSr©rÒrrrÑr©r!rÔrÕrrÚfthread sz9TestGreenlet.test_threaded_updatecurrent.<locals>.fthreadrrTr\) rVÚLockrÒÚobjectrrZbombrrWr]rÑr-r^)r0rØrÙrÜr±rxrrÛrÚtest_threaded_updatecurrentûs"
 
z(TestGreenlet.test_threaded_updatecurrentcsbg‰‡‡‡fdd„‰dd„‰tˆƒg‰ˆd ¡tˆˆdƒ‰ˆ ¡}| ˆ¡| |d¡dS)Nc
sJt ¡j ¡}ˆd=t ¡jˆ_zt ¡j |¡W5ˆ t ¡¡XdSr)rrrrr)rc©Ú    initiatorrr³rrr³,s  z>TestGreenlet.test_dealloc_switch_args_not_lost.<locals>.workercSsdSr¡rrrrrrá9szATestGreenlet.test_dealloc_switch_args_not_lost.<locals>.initiatorrr)rrr~r-rÍrràrÚ!test_dealloc_switch_args_not_lost*s 
 
z.TestGreenlet.test_dealloc_switch_args_not_lostcshtjddkrdd„‰nt‰Gdd„dtƒ}|ƒ‰tdd‰‡‡‡fd    d
„}t|ƒ}| | ¡ˆ¡dS) Nrr*cSs|||ŽdSrr)r«rLÚkrrrÚ_applyUsz0TestGreenlet.test_tuple_subclass.<locals>._applyc@seZdZdd„ZdS)z1TestGreenlet.test_tuple_subclass.<locals>.mytuplecSst ¡ ¡t |¡Sr)rrrÚtupleÚ__len__r2rrrræ[s z9TestGreenlet.test_tuple_subclass.<locals>.mytuple.__len__N)r rrrærrrrÚmytupleZsrçr)rLcsˆt ¡jjˆˆƒdSrr“r©rär‹ÚkwargsrrÚ switchapply`sz5TestGreenlet.test_tuple_subclass.<locals>.switchapply)rÚ version_infoÚapplyråÚdictrr-r)r0rçrêr!rrèrÚtest_tuple_subclassDs
 
z TestGreenlet.test_tuple_subclasscCsPtdtfdtdd„ƒiƒ}Gdd„d|ƒ}Gdd„d|ƒ}|ƒ| t|¡dS)    NÚAbstractSubclassr5cSsdSrrr2rrrr‡irˆz7TestGreenlet.test_abstract_subclasses.<locals>.<lambda>c@s eZdZdS)z:TestGreenlet.test_abstract_subclasses.<locals>.BadSubclassNr rrrrÚ BadSubclassksrðc@seZdZdd„ZdS)z;TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclasscSsdSrrr2rrrr5osz?TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclass.runN)r rrr5rrrrÚ GoodSubclassnsrñ)rrrr6r§)r0rïrðrñrrrÚtest_abstract_subclassesesýz%TestGreenlet.test_abstract_subclassescsNt ¡s dSt ¡d‰ˆdkr$dS‡‡fdd„}tdƒD]}|ƒr:qJq:dS)Nré2c    st ¡‰ˆ ¡t ¡‰ˆ ¡dg‰‡‡fdd„}tj|d}| ¡G‡‡‡fdd„dtƒ‰G‡fdd„dtƒ}g}tˆd    ƒ}t ¡}|ƒ}|D]<}d}ˆd
r¶|     d ¡dStƒ}ˆd
rÈqò| 
|¡q–t   ¡ˆd
rî|     d ¡dSˆ  |j|¡|D]}ˆ  |j|¡qd S) NFcsˆ ¡t ¡ˆ ¡dSrrÚrrÓrrÚanother_threadszWTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.another_threadrTcseZdZ‡‡‡fdd„ZdS)zTTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callbackcsˆ ¡ˆ ¡dˆd<dS)NTrrÐr2©rÔrÕÚrecycledrrrֈsz\TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callback.__del__Nr×rrõrrÚ gc_callback‡sr÷cseZdZ‡fdd„ZdS)zPTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbagecs||_ˆƒ|_dSr)ÚcycleÚcallbackr2©r÷rrrɍszYTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbage.__init__N)r rrrÉrrúrrÚgarbageŒsrûr*rr\T)rVrÝrÒrWr]rÞr/rrr^rrgrhr-r)    rôrxrûÚlr†Úcurrentr!Ú_Úlast©ÚNr0)r÷rÔrÕrörÚattempt{s>  
 
z?TestGreenlet.test_implicit_parent_with_threads.<locals>.attemptr,)rgÚ    isenabledZ get_thresholdr/)r0rrþrrrÚ!test_implicit_parent_with_threadsus - z.TestGreenlet.test_implicit_parent_with_threadscs|ddlm‰ddlm‰Gdd„dtƒ}t |¡}gˆ_‡‡‡fdd„}tdƒD]}||ƒ ¡qPˆ`ˆ t |¡|¡dS)    Nr©r)ric@s eZdZdS)zTTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.GreenletNr rrrrÚGreenletµsrcs8zˆƒj ¡Wn"ˆk
r2ˆj ˆƒ¡YnXdSr)rrÚgletsrr©rirr0rrÚ greenlet_main¾szYTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.greenlet_mainr\)    rrrirrPrr/rr-)r0rÚ initial_refsr    rþrrrÚ5test_issue_245_reference_counting_subclass_no_threads¬s  
 zBTestGreenlet.test_issue_245_reference_counting_subclass_no_threadsc
sèddlm}ddlm}ddlm‰Gdd„dtƒ‰g‰|ƒ‰‡fdd„‰‡‡‡‡‡fd    d
„}t ˆ¡}g}t|d ƒD]*}|ƒ}|||fd }| |¡|     ¡qx|D]}    |     
d ¡q¨ˆdd…=ˆ  ¡|  ¡|  t ˆ¡|¡dS)Nr)rW)rwrc@s eZdZdS)zSTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.MyGreenletNr rrrrÚ
MyGreenletÒsr csˆƒj ¡dSrrÌrrrrr    ØszVTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.greenlet_maincs8ˆˆƒ}ˆ |¡| ¡~| ¡ˆ d¡ˆƒdS)Nr\)rrrtru)Zgreenlet_running_eventZmine©r rrr    Z ref_clearedrrÚ thread_mainÛs
 
zTTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.thread_mainé-rŠr\)rVrWrwrrrrPr/rr]rurtrÁr-)
r0rWrwrr
Zthread_ready_eventsrþÚeventrœr™rr rÚ2test_issue_245_reference_counting_subclass_threadsËs.    
ÿ
 
 
z?TestGreenlet.test_issue_245_reference_counting_subclass_threadsc    CsDdd„}t|ƒ}dd„}t||ƒ}| t¡| ¡W5QRXdS)NcSsdS)Né rrrrrÚno_argssz\TestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.no_argscSsdSr¡rrrrrÚleafszYTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.leaf)rr6r§r)r0rÚparent_never_startedrÚchildrrrÚ>test_falling_off_end_switches_to_unstarted_parent_raises_errors 
 zKTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_errorcCs:dd„}t|ƒ}dd„}t||ƒ}| ¡}| |d¡dS)NcSs|dfS©Nérr…rrrÚone_argszUTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.one_argcSsdSr¡rrrrrr#szRTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.leaf)rrr‘)r0rrrrr²rrrÚ7test_falling_off_end_switches_to_unstarted_parent_workss 
zDTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_worksc    sˆGdd„dtƒ}|ƒ}g‰t‡fdd„|ƒ}| t¡| ¡W5QRX| ˆdg¡| t¡| ¡W5QRX| ˆdg¡dS)Nc@seZdZdd„ZdS)zXTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.ParentcSs|dkr t‚dSr4)r r·rrrr¶-sziTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parent.__getattribute__Nr¹rrrrÚParent,srcs
ˆ d¡Sr¡©rrrrrr‡4rˆzZTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.<lambda>r)rr6r rr-)r0rrrrrrÚ;test_switch_to_dead_greenlet_with_unstarted_perverse_parent+s  zHTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parentcsfg‰t‡fdd„ƒ}t‡fdd„ƒ}| ¡| ˆdg¡||_| ¡}| |¡| ˆddg¡dS)Ncs
ˆ d¡Srrrrrrr‡BrˆzDTestGreenlet.test_switch_to_dead_greenlet_reparent.<locals>.<lambda>cs
ˆ d¡Sr¡rrrrrr‡Crˆrr)rrr-rrC)r0rrr²rrrÚ%test_switch_to_dead_greenlet_reparent@s
z2TestGreenlet.test_switch_to_dead_greenlet_reparentN)F)-r rrr1r3r<r>rBrDrJrQr`rdrfrjrsryr‚rŽr’r•rr r¨r¬r¯r´rµr»r
rÅrÇrÈrÏrßrârîròrr rrrrrrrrrr$+sX , 
       8
 
/!7Cr$c@s\eZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z dS)ÚTestGreenletSetParentErrorsc    s¢i‰t ¡‰t ¡‰‡‡‡fdd„}dd„}tj|d}| ¡ˆ d¡t|ƒ}| ¡| t¡}ˆd|_    W5QRXˆ 
¡|  d¡|  t |jƒd¡dS)    Ncs&tdd„ƒˆd<ˆ ¡ˆ d¡dS)NcSsdSrrrrrrr‡VrˆzQTestGreenletSetParentErrors.test_threaded_reparent.<locals>.run.<locals>.<lambda>r!r\r–rr—rrr5Usz?TestGreenletSetParentErrors.test_threaded_reparent.<locals>.runcSst ¡j ¡dSrr“rrrrÚblankZszATestGreenletSetParentErrors.test_threaded_reparent.<locals>.blankrTr\r!z&parent cannot be on a different thread)rVrwrWr]rurrr6ržrrtr^r-r9r:)r0r5r!rœr!rrr—rÚtest_threaded_reparentPs 
 
z2TestGreenletSetParentErrors.test_threaded_reparentc    s g‰‡fdd„}tj|d}| ¡| d¡|j|jddG‡fdd„dtƒ}|d    d
„ƒ}| tj¡}|     ¡W5QRX| 
t |j ƒd ¡ˆdd…=dS) Ncs"tdd„ƒ}ˆ |¡| ¡dS)NcSsdSrrrrrrr‡lrˆzYTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker.<locals>.<lambda>)rrrrN©Úanotherrrr³ks 
zGTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.workerrTr\r)Zinitial_main_greenletscseZdZ‡fdd„ZdS)zKTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convolutedcs|dkrˆd|_t ||¡S©Nr5r©rrr¶r·r#rrr¶‡s
z\TestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convoluted.__getattribute__Nr¹rr#rrrΆsrÎcSsdSrrrrrrr‡‹rˆzITestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.<lambda>r¿) rVrWr]r^rÁZmain_greenlets_before_testrr6ršrr-r9r:)r0r³rxrÎr!rrr#rÚtest_unexpected_reparentingis  
  ÿz7TestGreenletSetParentErrors.test_unexpected_reparentingc    s¼g‰t ¡‰t ¡‰‡‡‡fdd„}G‡fdd„dtƒ}tj|d}| ¡ˆ d¡zB|dd„ƒ}| tj    ¡}| 
¡W5QRX|  t |j ƒd    ¡W5ˆ ¡| d¡ˆdd…=XdS)
Ncs4tdd„ƒ}ˆ |¡| ¡ˆ ¡ˆ d¡dS)NcSsdSrrrrrrr‡™rˆzhTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker.<locals>.<lambda>r\)rrrrtrurN©r$Zkeep_main_aliveZswitched_to_greenletrrr³˜s
 
zVTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.workercseZdZ‡fdd„ZdS)zZTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convolutedcs|dkrˆd|_t ||¡Sr%r&r·r#rrr¶Ÿs
zkTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convoluted.__getattribute__Nr¹rr#rrrΞsrÎrTr\cSsdSrrrrrrr‡©rˆzXTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.<lambda>rÀ)rVrwrrWr]rurtr^r6ršrr-r9r:)r0r³rÎrxr!rrr(rÚ*test_unexpected_reparenting_thread_running’s  
 
zFTestGreenletSetParentErrors.test_unexpected_reparenting_thread_runningc    CsNtdd„ƒ}| |jt ¡¡| t¡
}|`W5QRX| t|jƒd¡dS)NcSsdSrrrrrrr‡µrˆzGTestGreenletSetParentErrors.test_cannot_delete_parent.<locals>.<lambda>úcan't delete attribute)    rr@rrr6r7r-r9r:)r0r³rrrrÚtest_cannot_delete_parent´s
  z5TestGreenletSetParentErrors.test_cannot_delete_parentc    Cs4| t¡}t ¡`W5QRX| t|jƒd¡dS)Nr*©r6r7rrrr-r9r:©r0rrrrÚ!test_cannot_delete_parent_of_main¼s z=TestGreenletSetParentErrors.test_cannot_delete_parent_of_maincCs| t ¡j¡dSr)rCrrrr2rrrÚ!test_main_greenlet_parent_is_noneÂsz=TestGreenletSetParentErrors.test_main_greenlet_parent_is_nonecsTdd„}‡fdd„}t|ƒ}ˆ |¡||ƒ| ¡ˆ |¡||ƒ| ¡dS)NcSst ¡j ¡dSrr“rrrrÚbgÇszCTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.bgc
sNddˆdfD]<}ˆ t¡ }||_W5QRXˆ t|jƒdt|ƒj¡q dS)NrZ42z4GreenletChecker: Expected any type of greenlet, not )r6r§rr-r9r:Útyper )ÚgletÚprr2rrÚcheckËs  þzFTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.check)rr€rr~)r0r0r4r!rr2rÚtest_set_parent_wrong_typesÆs
 
 
z7TestGreenletSetParentErrors.test_set_parent_wrong_typesc    Cs>tdd„ƒ}| t¡ }||_W5QRX| t|jƒd¡dS)NcSsdSrrrrrrr‡ãrˆz@TestGreenletSetParentErrors.test_trivial_cycle.<locals>.<lambda>úcyclic parent chain)rr6ržrr-r9r:)r0r2rrrrÚtest_trivial_cycleâs  z.TestGreenletSetParentErrors.test_trivial_cyclec    Cs:| t¡}t ¡t ¡_W5QRX| t|jƒd¡dS)Nz(cannot set the parent of a main greenletr,r-rrrÚtest_trivial_cycle_mainès z3TestGreenletSetParentErrors.test_trivial_cycle_mainc    Csbtdd„ƒ}tdd„ƒ}tdd„ƒ}||_||_| t¡ }||_W5QRX| t|jƒd¡dS)NcSsdSrrrrrrr‡ïrˆz?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>cSsdSrrrrrrr‡ðrˆcSsdSrrrrrrr‡ñrˆr6)rrr6ržr-r9r:)r0r"rbZg3rrrrÚtest_deeper_cycleîs    z-TestGreenletSetParentErrors.test_deeper_cycleN) r rrr"r'r)r+r.r/r5r7r8r9rrrrr Os)"r c@sDeZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dS)ÚTestReprcCs| | |¡||f¡dSr)r~Úendswith)r0ÚgotÚsuffixrrrÚassertEndsWithüszTestRepr.assertEndsWithcCstt ¡ƒ}| |d¡dS)Nú current active started main>)Úreprrrr>©r0ÚrrrrÚtest_main_while_runningÿs z TestRepr.test_main_while_runningcs4t ¡‰‡fdd„}t|ƒ}| ¡}| |d¡dS)NcstˆƒSr)r@r©r±rrr5sz-TestRepr.test_main_in_background.<locals>.runú suspended active started main>)rrrr>)r0r5r!rBrrDrÚtest_main_in_backgrounds
 z TestRepr.test_main_in_backgroundcCsttƒƒ}| |d¡dS)Nz     pending>)r@rr>rArrrÚ test_initial s
zTestRepr.test_initialcs t ¡‰G‡fdd„dtjƒ}|ƒ}| ¡| d¡| |jd¡| |jd¡t    dƒD]}t
  d¡qZt    dƒD](}|  |j j¡t|j ƒ}| |d¡qrdS)    Ncs$eZdZdZZdZ‡fdd„ZdS)z/TestRepr.test_main_from_other_thread.<locals>.TNcs$tˆƒ|_t ¡|_t|jƒ|_dSr)r@Ú original_mainrrÚ    main_gletrr2rDrrr5s
 
z3TestRepr.test_main_from_other_thread.<locals>.T.run)r rrrHrrIr5rrDrrÚTsrJr\rEr?r%gü©ñÒMbP?z (thread exited) dead>)rrrVrWr]r^r>rHrr/rƒr„r~rIrHr@)r0rJrxrþrBrrDrÚtest_main_from_other_threads
 
z$TestRepr.test_main_from_other_threadcCsXtdd„ƒ}| ¡| t|ƒd¡| dt|ƒ¡| dt|ƒ¡| dt|ƒ¡dS)NcSsdSrrrrrrr‡4rˆz$TestRepr.test_dead.<locals>.<lambda>z dead>Z    suspendedÚstartedÚactive)rrr>r@Z assertNotInrArrrÚ    test_dead3s  zTestRepr.test_deadcCsXtdd„ƒ}tdd„ƒ}t ¡}|||fD](}| d|ft¡| d|ft¡q*dS)NcSsdSrrrrrrr‡?rˆz>TestRepr.test_formatting_produces_native_str.<locals>.<lambda>cSsdSrrrrrrr‡@rˆz%sz%r)rrÚassertIsInstancer9)r0Zg_deadZ g_not_startedZg_curr!rrrÚ#test_formatting_produces_native_str;s  þþz,TestRepr.test_formatting_produces_native_strN)
r rrr>rCrFrGrKrNrPrrrrr:ús    #r:c@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestMainGreenletcCs4dtt ¡ƒkst‚tt ¡ƒ}dt|ƒks0t‚|S)Nr±)r@rrÚAssertionErrorr1)r0rxrrrÚ_check_current_is_mainSs z'TestMainGreenlet._check_current_is_maincCs$| ¡}td|fiƒ}| |¡dS)NÚsubclass)rSr1r?)r0Z    main_typerTrrrÚ)test_main_greenlet_type_can_be_subclassed[sz:TestMainGreenlet.test_main_greenlet_type_can_be_subclassedcCs| ¡| t ¡t¡dSr)rSrOrrr2rrrÚtest_main_greenlet_is_greenlet`sz/TestMainGreenlet.test_main_greenlet_is_greenletN)r rrrSrUrVrrrrrQOsrQÚ__main__)Ú
__future__rrrrgrrƒrVÚabcrrrÚr    Z    leakcheckr
rlr rr#r$r r:rQr Zunittestr±rrrrÚ<module>s6              *,U