python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test__xxinterpchannels.cpython-312.pyc

͑e>ddlmZddlZddlZddlmZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZe
jdZdZifdZGd	d
ed
dZej(dZGd
deddZGddeddZdddZdZdZGddej6ZGddeZGddeZGddeZGd d!ed!d"Z ejBd#Gd$d%eZ"e#d&k(rejHyy)')
namedtupleN)dedent)
import_helper)interpreters_run_outputclean_up_interpreters_xxinterpchannelsct|||yN)_run_interp)idsourceshareds   O/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test__xxinterpchannels.py
run_interpr"sFF#ct|}tj}||k(r*tj|k7rtt||ytj|||yr)rrget_mainget_currentRuntimeErrorexec
run_string)r
rr_mainnsmains     rrr&sS
F^F  "Drz##%-VWFF3rc0eZdZedZdfd	ZxZS)InterpretercZt||r|St|tr||Str)
isinstancestrNotImplementedError)clsraws  rfrom_rawzInterpreter.from_raw4s*c3J
S
!s8O%%rcxtj}||k(r'|sd}n|dk7rtdj||}ng|E|sd}n|dk(rtdt	|tj
s6tj
|}n |r|dk(rd}|}ntj}t|!|||}|S)Nrz)name mismatch (expected "main", got "{}")interpz!name mismatch (unexpected "main"))	rr
ValueErrorformatr
InterpreterIDcreatesuper__new__)r!namer
rself	__class__s     rr+zInterpreter.__new__=s$$&
: ?FFtLNNB
^ !DEEb,"<"<=!//3DB$$&BwsD"-rNN)__name__
__module____qualname__classmethodr#r+
__classcell__r.s@rrr2s&&rrzname idc#TK	dJd#tj$rYywxYww)Nzchannel not closed)channelsChannelClosedErrorrrexpect_channel_closedr:Xs2+
	+**&&

s((%(%(c2eZdZdfd	ZdZdZdZxZS)
ChannelActionc<|sd}|sd}t|||||}|S)Nbothrr*r+)r!actionendr%r-r.s     rr+zChannelAction.__new__ds,CFwsFC8rc:|jdk(r#|jdvr[t|j|jdvr#|jdvr*t|jt|j|jdvrt|jy)Nuse)sameoppositesendrecvcloseforce-close)r>rDrErFrG)rrDotherextra)r@rAr&r%)r-argskwargss   r__init__zChannelAction.__init__ls;;%xxCC **
[[4
4xxKK **T[[));;@@T[[))Arcl|jdk(r|S|jdk(r	|dk(rdSdS|jS)NrDrErFrGrAr-rAs  rresolve_endzChannelAction.resolve_endxs988vJ
XX
# F]66688Orc|jdk(r|S|jdk(r
|t|S|jdk(r
|t|S|jdk(r*|jdk(r|S|r|jdk(r|Sty)NrDrKrLr)r%rr,)r-r%rKrLs    rresolve_interpzChannelAction.resolve_interps;;& M
[[G
#}""L
[[G
#}""L
[[F
"{{f$
5::/""
#rr/)r0r1r2r+rOrSrUr4r5s@rr<r<bs
*#rr<zaction end interpc>eZdZd	ddfdZdZdZdddZxZS)
ChannelStateFclosedc*t||||}|Srr?)r!pendingrYr-r.s    rr+zChannelState.__new__swsGV4rcVt||jdz|jSNrXtyper[rYr-s rincrzChannelState.incr"tDz$,,*4;;??rcVt||jdz
|jSr]r_ras rdecrzChannelState.decrrcrTforcec|jr|r|jdk(r|St||rddS|jdS)NrTrX)rYr[r`)r-rgs  rrIzChannelState.closes?;;DLLA-tDzu!tDD$,,tDDr)r)r0r1r2r+rbrerIr4r5s@rrWrWs,%@@"EErrWzpending closedT
hideclosedc|jr|dk(r|dk(r|jrd}nd}nd}	t||||}|rd|S#tj$r|s|s|j}Y|SwxYw)NrCrGFT.)rYr[_run_actionr7r8rI)cidr@rAstaterj
expectfailresults       r
run_actionrqs||U?sf}JJ
S&#u5IM&&*MsA(A,+A,cR|dk(r|dk(r&tj|d|jS|dk(rR|js!	tj	|tdtj	||jSt||dk(r1i}|dvrd||<tj|fi||jS|d	k(r5d
di}|dvrd||<tj|fi||jdSt|#tj$r|cYSwxYw)NrCrFspamrGzexpected ChannelEmptyErrorrIrGrFTrJrgrf)
r7rFrbr[rG	ExceptionChannelEmptyErrorrer&rI)rmr@rArnrNs     rrlrls'
&=MM#w'::<
F]==BMM#&$$@AA

c"zz|#S/!	7	""F3Ks%f%{{}	=	 T""F3Ks%f%{{{&&  1 11! L!sDD&%D&ctjD]}	tj|y#tj$rY1wxYwr)r7list_alldestroyChannelNotFoundErrorrms rclean_up_channelsr|sG  "	S!,,		s1AAceZdZdZy)TestBasec,ttyr)r|rras rtearDownzTestBase.tearDownsrN)r0r1r2rr9rrr~r~s rr~cHeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
Zy)ChannelIDTestsctjdd}|jt|d|j|jdy)N
Trfr>)r7_channel_idassertEqualintrAr-rms  rtest_default_kwargsz"ChannelIDTests.test_default_kwargss?""2T"2S2&&)rctjddd}|j|jdtjdddd}|j|jdtjddd}|j|jdtjdddd	}|j|jdtjdddd}|j|jd
y)NrTrFrgrFFrFrGrgrGrgrG)rGrFrgr>)r7rrrArs  rtest_with_kwargszChannelIDTests.test_with_kwargss""2D"=&)""2DuD"I&)""2D"=&)""2DuD"I&)""2Dt4"H&)rcGddt}tj|d}|jt	|dy)NceZdZdZy)*ChannelIDTests.test_coerce_id.<locals>.IntcyNrr9ras r	__index__z4ChannelIDTests.test_coerce_id.<locals>.Int.__index__
srN)r0r1r2rr9rrIntrs
rrTrfr)rr7rrr)r-rrms   rtest_coerce_idzChannelIDTests.test_coerce_ids;	#	""35"5S2&rc|jttjt	|jttjd|jttjd|jttjd|jt
tjd|jttjdy)Ng$@10s10l)assertRaises	TypeErrorr7robjectr&
OverflowErrorras rtest_bad_idzChannelIDTests.test_bad_ids)X%9%968D)X%9%94@)X%9%94@)X%9%95A*h&:&:B?-)=)=uErc|jt5tjddddddy#1swYyxYw)NrFrFrG)rr&r7rras rtest_bad_kwargszChannelIDTests.test_bad_kwargss:


z
*	=  %e <	=	=	=s	8Actj}|jtj5tj	t|dzdddy#1swYyxYwNr^)r7r)rrzrrrs  rtest_does_not_existz"ChannelIDTests.test_does_not_existsMoo


x<<
=	/  SA.	/	/	/s"AA(chtjdd}|jt|dy)NrTrfr)r7rrrrs  rtest_strzChannelIDTests.test_str$s+""2T"2S4(rctjdd}|jt|dtjddd}|jt|dtjddd}|jt|dtjdddd	}|jt|dy)
NrTrfz
ChannelID(10)rzChannelID(10, send=True)rzChannelID(10, recv=True)r)r7rrreprrs  r	test_reprzChannelIDTests.test_repr(s""2T"2cO4""2D"=c$>?""2D"=c$>?""2Dt4"HcO4rctj}tjt|}tj}|j	||k(|j	||k(|j	|t|k(|j	t||k(|j	|tt|k(|j	tt||k(|j
|tt|dzk(|j
|tt|k(|j
|ddzk(|j
|tdk(|j
|dk(|j
||k(|j
||k7|j
||k7|j	||k7y)N皙?infspam)r7r)rr
assertTruefloatassertFalser)r-cid1cid2cid3s    r
test_equalityzChannelIDTests.test_equality5sm ##CI. %%D	)*D	T)*c$i 001c$i(D01s4y!1C!778SY/0D)u-.(&&&%rctj}tj}tj||tj|}|j	|||jt
|t
|yr)r7r)rFrGrassertIsr`)r-chanobjgots    rtest_shareablezChannelIDTests.test_shareableKs\ oo

dC mmD!c"

d3ic+rN)
r0r1r2rrrrrrrrrrr9rrrrs5** 'F=/
)5&,,rrc eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZej4ddZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+y))*ChannelTestscltj}|j|tjyr)r7r)assertIsInstance	ChannelIDrs  rtest_create_cidzChannelTests.test_create_cidZs$ooc8#5#56rctj}tj}tj}tj}tj}|j|t	|dz|j|t	|dz|jt|t|z
|||hyr)r7rxr)rrset)r-beforeid1id2id3afters      rtest_sequential_idsz ChannelTests.test_sequential_ids^s""$oooooo!!#c#hl+c#hl+Uc&k1Cc?CrcHtj}t|td}t	|j}tj}t|td}t	|j}|j
|t	|dzy)Nz{
            import _xxinterpchannels as _channels
            cid = _channels.create()
            print(cid)
            r^)rr)rrrstripr)r-routrrrs      rtest_ids_globalzChannelTests.test_ids_globalis!!##v' 
399;!!##v' 
399;s4y1}-rctj}tj|d}tj|d}|j|g|j|gy)z=Test listing interpreters for a channel with no associations.TrFFN)r7r)list_interpretersr)r-rmsend_interpsrecv_interpss    r#test_channel_list_interpreters_nonez0ChannelTests.test_channel_list_interpreters_none|sZoo11#D1A11#E1Br*r*rc(tj}tj}tj	|dtj|d}tj|d}|j
||g|j
|gtj}t|td|dtj|d}tj|d}|j
||g|j
||gy)z(Test basic listing channel interpreters.rFTrFT
            import _xxinterpchannels as _channels
            obj = _channels.recv()
            N)	rrr7r)rFrrrr)r-interp0rmrrinterp1s      r$test_channel_list_interpreters_basicz1ChannelTests.test_channel_list_interpreters_basics'')oo

c6"11#D1A11#E1By1r*%%'GV)""%'
%	
 11#D1A11#E1By1y1rc^tj}tj}tj}tj}tj}tj	|dt|t
d|dt|t
d|dt|t
d|dtj|d}tj|d}|jt|||h|jt|||hy	)
z?Test listing interpreters for a channel with many associations.rFN
            import _xxinterpchannels as _channels
            _channels.send(z, "send")
            rrTrFN)
rrr)r7rFrrrrr)r-rrinterp2interp3rmrrs        r'test_channel_list_interpreters_multiplez4ChannelTests.test_channel_list_interpreters_multiples''')%%'%%'%%'oo

c6"GV)5!
%		GV)""%'
%		GV)""%'
%	 11#D1A11#E1B\*Wg,>?\*Wg,>?rcRtj}tj}tj}tj	|dt|t
d|dtj|d}tj|d}|j||g|j||gtj|tj|d}tj|d}|j||g|j|gy)z?Test listing channel interpreters with a destroyed interpreter.rFrrTrFN)
rrr)r7rFrrrrryr-rrrmrrs      r(test_channel_list_interpreters_destroyedz5ChannelTests.test_channel_list_interpreters_destroyeds'')%%'oo

c6"GV)""%'
%	
 11#D1A11#E1By1y1W%11#D1A11#E1By1r*rctj}tj}tj}tj}tj	|dt|t
d|dtj	|dt|t
d|dtj|d}tj|d}|jt|d|jt|dtj|dtj|d}tj|d}|jt|d	|jt|dt|t
d
|dtj|d}tj|d}|jt|d	|j||gy)z:Test listing channel interpreters with a released channel.datarrTrFr^rrQ
            import _xxinterpchannels as _channels
            _channels.release(N)rrr)r7rFrrrrlenrelease)r-rrrrmrrs       r'test_channel_list_interpreters_releasedz4ChannelTests.test_channel_list_interpreters_releaseds'')%%'%%'oo

c6"GV)""%'
%		

c6"GV)""%'
%	
 11#D1A11#E1B\*A.\*A.	4(11#D1A11#E1B\*A.\*A.	GV)"e$
%	
 11#D1A11#E1B\*A.y1rctj}tj}tj}tj	|dtj|d}tj|d}|j
t|d|j
t|dtj|d|jtj5tj|dddd|jtj5tj|ddddy#1swYIxYw#1swYyxYw)	z8Test listing channel interpreters with a closed channel.rFTrFr^rrfN)rrr)r7rFrrrrIrr8rs      r%test_channel_list_interpreters_closedz2ChannelTests.test_channel_list_interpreters_closeds'')%%'oo

c6" 11#D1A11#E1B\*A.\*A.	s$'


x::
;	7&&s&6	7


x::
;	8&&s&7	8	8	7	7	8	8s-E
,E
EE"ctj}tj}tj}tj	|dtj|d}tj|d}|j
t|d|j
t|dtj|d|jtj5tj|ddddtj|d}|j
t|dt|td|d	y#1swYUxYw)
zCTest listing channel interpreters with a channel's send end closed.rFTrFr^rNO
            import _xxinterpchannels as _channels
            _channels.close(, force=True)
            )
rrr)r7rFrrrrIrr8rrrs      r.test_channel_list_interpreters_closed_send_endz;ChannelTests.test_channel_list_interpreters_closed_send_end
s4'')%%'oo

c6" 11#D1A11#E1B\*A.\*A.	s&


x::
;	7&&s&6	7 11#E1B\*A.	GV) E"
%			7	7s-EE"ctj}d}tj||tj|}|j	|||j||yNrs)r7r)rFrGrassertIsNot)r-rmorigrs    rtest_send_recv_mainz ChannelTests.test_send_recv_main2sOoo

c4 mmC d#d#rcVtj}t|td}y)Na

            import _xxinterpchannels as _channels
            cid = _channels.create()
            orig = b'spam'
            _channels.send(cid, orig)
            obj = _channels.recv(cid)
            assert obj is not orig
            assert obj == orig
            )rr)rr)r-rrs   rtest_send_recv_same_interpreterz,ChannelTests.test_send_recv_same_interpreter;s(!!##v' rctj}tj}t|t	d|d}tj|}|j
|dy)Nr, b'spam')
            rs)r7r)rrrrGr)r-rmrrrs     r%test_send_recv_different_interpretersz2ChannelTests.test_send_recv_different_interpretersGscoo!!##v+5!
' mmC g&rctjfd}tj|}|j	tjd|j
tj}|j|dy)Nc		tj}	tj|y#tj$rtjdYnwxYw])Nr)r7rGrvtimesleeprF)rrms rfz8ChannelTests.test_send_recv_different_threads.<locals>.fUsS$"--,C
MM#s# 11$JJsO$	s1(AAtargetrs)	r7r)	threadingThreadstartrFjoinrGr)r-rtrrms    @r test_send_recv_different_threadsz-ChannelTests.test_send_recv_different_threadsRsdoo	$
A&		

c7#	mmC g&rcRtjtjdfd}tj|}|jtj
d|jtj}|j|dy)Nc
>ttdddy)Nz
                import time
                import _xxinterpchannels as _channels
                while True:
                    try:
                        obj = _channels.recv(z)
                        break
                    except _channels.ChannelEmptyError:
                        time.sleep(0.1)
                assert(obj == b'spam')
                _channels.send(z, b'eggs')
                )rr)rmrrsrrzIChannelTests.test_send_recv_different_interpreters_and_threads.<locals>.fks8c6/.
/2U3 
!$u%+$Crrrseggs)
r7r)rrrrrFrrGr)r-rrrrmrrs    @@@r1test_send_recv_different_interpreters_and_threadsz>ChannelTests.test_send_recv_different_interpreters_and_threadsfswoo!!#
	
A&		

c7#	mmC g&rc|jtj5tjdddddy#1swYyxYw)Nrrs)rr7rzrFras rtest_send_not_foundz ChannelTests.test_send_not_founds9


x<<
=	'MM"g&	'	'	'sAA	c|jtj5tjddddy#1swYyxYwr)rr7rzrGras rtest_recv_not_foundz ChannelTests.test_recv_not_founds7


x<<
=	MM"			s	?Actj}|jtj5tj	|dddy#1swYyxYwr)r7r)rrvrGrs  rtest_recv_emptyzChannelTests.test_recv_emptysCoo


x99
:	MM#			sAAct}tj}tj||}tj	|dtj	|dtj	|dtj	|dtj||}tj||}tj|}tj||}tj||}|j|||j|d|j
|d|j
|d|j
|d|j||y)Nr^rsr)rr7r)rGrFrr)	r-defaultrmobj1obj2obj3obj4obj5obj6s	         rtest_recv_defaultzChannelTests.test_recv_defaults(oo}}S'*

c4 

c1

c7#

c7#}}S'*}}S'*}}S!}}S'*}}S'*

dG$

dD!q!w'w'

dG$rc	|jd5tj}tj}tj|td|dtj||jtd|d5tj|ddd~ddd|jd5tj}tj}tj|td|dtj|dtj|tj||jtd|d5tj|ddd~dddy#1swYxYw#1swYxYw#1swY+xYw#1swYyxYw)	NrYzV
                import _xxinterpchannels as _channels
                _channels.send(, b'spam')
                zchannel z
 is closedz
still openrz	 is empty)subTestr7r)rrrryassertRaisesRegexrrGrF)r-rr%rs    r"test_recv_sending_interp_destroyedz/ChannelTests.test_recv_sending_interp_destroyeds
\\(
#	??$D!((*F##FF8  $v&4-

  (''*24&
(CE
$

d#
$	\\,
'	??$D!((*F##FF8  $v&4-

MM$(  (MM$''*24&	(BD
$

d#
$			
$
$		0
$
$		sIA;F
F#	FB&F7+F+	F7F	FF(+F4	0F77GcPtj}gd}|D]}}|j|5tj||tj	|}|j|||j
t|t|dddy#1swYxYw)N)Nrrs*)r7r)rrFrGrrr`)r-rmobjectsrrs     rtest_allowed_typeszChannelTests.test_allowed_typessoo
	4Cc"
4

c3'mmC(  c*

d3ic3
4
4	4
4
4sA"BB%	c6tj}tj}t|t	dt|j}tj|}|j|d|j|jdy)Nz
            import _xxinterpchannels as _channels
            print(cid.end)
            _channels.send(cid, b'spam')
            r{rsrF)
r7r)rrrdictrFrGrrr-rmr%rrs     rtest_run_string_arg_unresolvedz+ChannelTests.test_run_string_arg_unresolvedsxoo$$&&&*#

SXX mmC g&f-rz(disabled until high-level channels existcdtj}tj|d}tj}t	|tdt
|j}tj|}|j|d|j|jdy)NT)_resolvez
            import _xxinterpchannels as _channels
            print(chan.id.end)
            _channels.send(chan.id, b'spam')
            )rrsrF)r7r)rrrrr#rFrGrrr$s     rtest_run_string_arg_resolvedz)ChannelTests.test_run_string_arg_resolvedsoo""3"6$$&&&*#

chh!mmC g&f-rctj}tj|dtj|tj	||jtj5tj|dddd|jtj5tj|dddy#1swYGxYw#1swYyxYwNrsrr7r)rFrGrIrr8rs  rtest_close_single_userz#ChannelTests.test_close_single_usersoo

c7#

cs


x::
;	(MM#w'	(


x::
;	MM#			(	(		4C2CCC&c	"tj}tj}tj}tj|t	d|dtj|t	d|dtj||j
tj5}tj|t	d|dddd|jdtj|j
tj5}tj|t	d|dddd|jdt|jy#1swYxYw#1swY;xYw)NrrzN
            import _xxinterpchannels as _channels
            _channels.recv(rz 
                _channels.send(rr8)r7r)rrrrIrRunFailedErrorassertInr	exception)r-rmrrcms     rtest_close_multiple_usersz&ChannelTests.test_close_multiple_usersspoo!!#!!#V15!
-&		V15!
-&		s


|::
;	r##C5  #u%1*
		


*C,=>


|::
;	r##C5  #u%1*
		


*C,=>		
		s7$E9'$F9FFc>tj}tj|dtj|tj	||jtj5tj	|dddy#1swYyxYwrr+rs  rtest_close_multiple_timesz&ChannelTests.test_close_multiple_timessioo

c7#

cs


x::
;	 NN3	 	 	 s4BBcFgd}|D]\}}|j||f5tj}tj|dtj	|tj||||j
tj5tj|dddd|j
tj5tj	|ddddddy#1swYQxYw#1swY xYw#1swYxYw)N))FFTF)FT)TTrsrr)rr7r)rFrGrIrr8)r-testsrFrGrms     rtest_close_emptyzChannelTests.test_close_empty&s 
	'JD$tTl+	
'oo'

c7+

c"sD9&&x'B'BC0MM#w/0&&x'B'BC'MM#&'	
'	
'
	'00''	
'	
's<A7DC>.'DD
+D>DD
DDD 	cltj}tj|dtj|d|jtj5tj|dddtj
|tj|dy#1swY5xYw)Nrshamrr7r)rFrChannelNotEmptyErrorrIrGrs  r%test_close_defaults_with_unused_itemsz2ChannelTests.test_close_defaults_with_unused_items9syoo

c7#

c6"


x<<
=	 NN3	 

c

c7#	 	 s B**B3ctj}tj|dtj|d|jtj5tj|ddddtj
|tj|dtj
|tj
|tj|dy#1swYvxYw)Nrsr;TrGrr<rs  r*test_close_recv_with_unused_items_unforcedz7ChannelTests.test_close_recv_with_unused_items_unforcedCsoo

c7#

c6"


x<<
=	+NN3TN*	+

c

c7#

c

cs&
	+	+s C--C6c,tj}tj|dtj|dtj|d|j	tj
5tj|ddddtj
|tj
||j	tj
5tj
|dddy#1swYqxYw#1swYyxYw)Nrsr;Trrr7r)rFrIrr8rGrs  r*test_close_send_with_unused_items_unforcedz7ChannelTests.test_close_send_with_unused_items_unforcedPsoo

c7#

c6"s&


x::
;	(MM#w'	(

c

c


x::
;	MM#				(	(		s7C>D
>D
Dctj}tj|dtj|d|jtj5tj|dddddtj
|tj|dtj
|tj
|tj|dy#1swYvxYw)Nrsr;Trtrr@r<rs  r*test_close_both_with_unused_items_unforcedz7ChannelTests.test_close_both_with_unused_items_unforced]soo

c7#

c6"


x<<
=	6NN3TN5	6

c

c7#

c

cs&
	6	6s C..C7ctj}tj|dtj|dtj|dd|j	tj
5tj|dddd|j	tj
5tj
|dddy#1swYGxYw#1swYyxYw)Nrsr;TrrrCrs  r(test_close_recv_with_unused_items_forcedz5ChannelTests.test_close_recv_with_unused_items_forcedjoo

c7#

c6"sT2


x::
;	(MM#w'	(


x::
;	MM#			(	(		8C6C!C!C*ctj}tj|dtj|dtj|dd|j	tj
5tj|dddd|j	tj
5tj
|dddy#1swYGxYw#1swYyxYw)Nrsr;TrrrCrs  r(test_close_send_with_unused_items_forcedz5ChannelTests.test_close_send_with_unused_items_forcedurIrJctj}tj|dtj|dtj|ddd|j	tj
5tj|dddd|j	tj
5tj
|dddy#1swYGxYw#1swYyxYw)Nrsr;TrrrCrs  r(test_close_both_with_unused_items_forcedz5ChannelTests.test_close_both_with_unused_items_forcedsoo

c7#

c6"sD=


x::
;	(MM#w'	(


x::
;	MM#			(	(		s9C7C"C"C+c|tj}tj||jtj5tj|dddd|jtj5tj
|dddy#1swYGxYw#1swYyxYwr)r7r)rIrr8rFrGrs  rtest_close_never_usedz"ChannelTests.test_close_never_usedsoos


x::
;	(MM#w'	(


x::
;	MM#			(	(			B&B2&B/2B;ctj}tj|dtj}tj|td|d|j
tj5tj|ddd|j
tj5tj|dddy#1swYGxYw#1swYyxYw)Nrsrr)
r7r)rFrrrrr8rGrIr-rmr%s   r!test_close_by_unassociated_interpz.ChannelTests.test_close_by_unassociated_interpsoo

c7#$$&4 E"
0)	

x::
;	MM#	


x::
;	 NN3	 	 			 	 sC>C)C&)C2c.tj}tj|dtj|dtj|dtj|tj	|d|jtj5tj|dddd|jtj5tj|dddy#1swYGxYw#1swYyxYw)NrsTrfrr+rs  r-test_close_used_multiple_times_by_single_userz:ChannelTests.test_close_used_multiple_times_by_single_usersoo

c7#

c7#

c7#

cs$'


x::
;	(MM#w'	(


x::
;	MM#			(	(		s"C? D?DDctj}|jtj5tj	dddddtj||jtj5tj	|ddddy#1swY^xYw#1swYyxYw)NrTr)r7r)rrzrrIr8rs  r.test_channel_list_interpreters_invalid_channelz;ChannelTests.test_channel_list_interpreters_invalid_channelsoo


x<<
=	8&&t$&7	8	s


x::
;	7&&s&6	7	7	8	8
	7	7sB)B5)B25B>ctj}|jt5tj	|dddy#1swYyxYwr)r7r)rrrrs  r+test_channel_list_interpreters_invalid_argsz8ChannelTests.test_channel_list_interpreters_invalid_argss?oo


y
)	,&&s+	,	,	,sA		AN),r0r1r2rrrrrrrrrrrrrrr	rr
rrrr!r%unittestskipr(r,r3r5r9r>rArDrFrHrLrNrPrTrVrXrZr9rrrrXs7	D.&+2,@4+.)2V8,!8J$
	''('8'
%*<4&
.$X]]=>.?.$	?0 '&$''			 	7,rrcPeZdZdZ		dZdZdZdZdZdZ	dZ
d	Zd
ZdZ
y)
ChannelReleaseTestsa
    - main / interp / other
    - run in: current thread / new thread / other thread / different threads
    - end / opposite
    - force / no force
    - used / not used  (associated / not associated)
    - empty / emptied / never emptied / partly emptied
    - closed / not closed
    - released / not released
    - creator (interp) / other
    - associated interpreter not running
    - associated interpreter destroyed
    ctj}tj|dtj|tj	|dd|jtj5tj|dddd|jtj5tj|dddy#1swYGxYw#1swYyxYwNrsTrrr7r)rFrGrrr8rs  rtest_single_userz$ChannelReleaseTests.test_single_usersoo

c7#

c4d3


x::
;	(MM#w'	(


x::
;	MM#			(	(		s7C5C C C)c
tj}tj}tj}tj|t	d|dt|t	d|d|d}tj|t	d|d|j
|jdy)	Nrrrz )
            _channels.release(z+)
            print(repr(obj))
            z
            _channels.release(rzb'spam')r7r)rrrrrr)r-rmrrrs     rtest_multiple_usersz'ChannelReleaseTests.test_multiple_userssoo!!#!!#V15!
-&	#v+""%'"e$
' 	V1"e$
-&		
i0rctj}tj|dtj|tj	||jtj5tj|dddd|jtj5tj|dddy#1swYGxYw#1swYyxYwr*rars  rtest_no_kwargsz"ChannelReleaseTests.test_no_kwargs
soo

c7#

c


x::
;	(MM#w'	(


x::
;	MM#			(	(		r-cJtj}tj|dtj|tj	|dd|jtj5tj	|dddddy#1swYyxYw)NrsTrrars  rtest_multiple_timesz'ChannelReleaseTests.test_multiple_timess{oo

c7#

c4d3


x::
;	8St$7	8	8	8s7BB"cFtj}tj|dtj|dtj|dd|j	tj
5tj
|dddy#1swYyxYw)Nrsr;Tr)r7r)rFrrr8rGrs  rtest_with_unused_itemsz*ChannelReleaseTests.test_with_unused_itemsstoo

c7#

c6"4d3


x::
;	MM#			s8BB c|tj}tj||jtj5tj|dddd|jtj5tj
|dddy#1swYGxYw#1swYyxYwr)r7r)rrr8rFrGrs  rtest_never_usedz#ChannelReleaseTests.test_never_used'soo


x::
;	(MM#w'	(


x::
;	MM#			(	(		rQctj}tj|dtj}tj|td|dtj
|}tj||jtj5tj|dddd|j|dy#1swYxYw)Nrsrrr)r7r)rFrrrrGrrr8r)r-rmr%rs    rtest_by_unassociated_interpz/ChannelReleaseTests.test_by_unassociated_interp0soo

c7#$$&4"e$
0)	mmC 


x::
;	(MM#w'	(g&	(	(s+CC&c
2tj}tj}tj|t	d|d|d|jtj5tj|dddy#1swYyxYw)NzT
            import _xxinterpchannels as _channels
            obj = _channels.send(z), b'spam')
            _channels.release(r)r7r)rrrrr8rGrSs   rtest_close_if_unassociatedz.ChannelReleaseTests.test_close_if_unassociated?soo$$&4""%'"e$
0)	

x::
;	MM#			s.B

Bc*tj}tj|dtj|tj|dtj	|dtj|}|j|dy)NrsTr)r7r)rFrGrr)r-rmrs   rtest_partiallyz"ChannelReleaseTests.test_partiallyLsgoo

c4 

c

c7#4(mmC g&rc0tj}tj|dtj|dtj|dtj|tj	|dd|jtj5tj|dddd|jtj5tj|dddy#1swYGxYw#1swYyxYwr`rars  r'test_used_multiple_times_by_single_userz;ChannelReleaseTests.test_used_multiple_times_by_single_userWsoo

c7#

c7#

c7#

c4d3


x::
;	(MM#w'	(


x::
;	MM#			(	(		s#D!DD	DN)r0r1r2__doc__rbrdrfrhrjrlrnrprrrtr9rrr^r^sC"	1(	8
'	'rr^cteZdZdZfdZedZedZdZd
dZ	dZ
dZd	Zd
Z
dZdZxZS)ChannelCloseFixtureFcv|dvsJ|jri}netj|}tj|}tj|}|j||j||j|i}|sd}t|||||||}t
|_t|_	||_
|S)NrrD)QUICKrr#r,r*r+r_preppedrW_state_known)	r!rAr%rKrLcreatorknownr-r.s	        rr+zChannelCloseFixture.__new__ls&&&99E ))&1F((/E((/EV

E

EE
GwsCwG
"nrc|jSrr{ras rrnzChannelCloseFixture.states{{rc	|jS#t$r@|j|j}|j	||_|jcYSwxYwr)_cidAttributeError_get_interpreterr}_new_channel)r-r}s  rrmzChannelCloseFixture.cidsP	99	++DLL9G))'2DI99	sAAAcJ|j|}|j||Sr)r_prep_interpreterr-r%s  rget_interpreterz#ChannelCloseFixture.get_interpreters%&&v.v&
rc||j}|dk(r|jjdk(ryt|jjS)NrGrFF)rArnrYboolrRs  rexpect_closed_errorz'ChannelCloseFixture.expect_closed_errors@;((C&=TZZ..&8DJJ%%&&rc&|j|yr)rrs  rprep_interpreterz$ChannelCloseFixture.prep_interpretersv&rc||_yrr)r-r@rps   r
record_actionz!ChannelCloseFixture.record_actions	rc,ttyr)rr|ras rclean_upzChannelCloseFixture.clean_upsrc|jdk(rtjStj}t|jd|dtj||_|jS)Nrz
                import _xxsubinterpreters
                cid = _xxsubchannels.create()
                # We purposefully send back an int to avoid tying the
                # channel to the other interpreter.
                _xxsubchannels.send(zC, int(cid))
                del _xxsubinterpreters
                )r,r7r)rr
rGr)r-r}chs   rrz ChannelCloseFixture._new_channelsg<<6!??$$"Bwzz(%
&(D)$
!

b)DIyyrc|dvr|jS|dk(r|jS|dk(r|jS|}	|j|}|S#t$rt|x}|j|<Y|SwxYw)N)rDr%rKrL)r%rKrLr|KeyErrorr)r-r%r,s   rrz$ChannelCloseFixture._get_interpreters'';;
w
::
w
::D
?T*M
?-8->>T*M
?sA#A.-A.c|j|jvry|jj|j|jdk(ryt	|jd|j
dy)Nra

            import _xxinterpchannels as channels
            import test.test__xxinterpchannels as helpers
            ChannelState = helpers.ChannelState
            try:
                cid
            except NameError:
                cid = channels._channel_id(r)r
rzaddr,rrmrs  rrz%ChannelCloseFixture._prep_interpretersb99

%

&))$;;& 699#,-1HH:6
	rr)r0r1r2ryr+propertyrnrmrrrrrrrrr4r5s@rrwrwes_

E*
'' 
rrwzend interp other extra creatorz%these tests take several hours to runcreZdZdZ		dZdZdZdZdZddd	Z	d
Z
dZdd
ZdZ
ddZdZdZdZy)ExhaustiveChannelTestsa
    - main / interp / other
    - run in: current thread / new thread / other thread / different threads
    - end / opposite
    - force / no force
    - used / not used  (associated / not associated)
    - empty / emptied / never emptied / partly emptied
    - closed / not closed
    - released / not released
    - creator (interp) / other
    - associated interpreter not running
    - associated interpreter destroyed

    - close after unbound
    c#<Kg|jddD]"}||jD]	}||z$|jddD]"}||jD]	}||z$|jddD]~}||jddD]'}||z}||jD]	}||z)|jddD]'}||z}||jD]	}||z)|jddD]~}||jddD]'}||z}||jD]	}||z)|jddD]'}||z}||jD]	}||z)yw)NrDrKrL)_iter_close_action_sets_iter_post_close_action_sets_iter_use_action_sets)r-closeactionspostactions
useactionsactionss     riter_action_setsz'ExhaustiveChannelTests.iter_action_setss!88I	1L#@@B
1"[00
1	1!88'J	1L#@@B
1"[00
1	144VWE	0J $ < <VW M
0$|3
#'#D#D#F0K!K//0
0
!% < <Wg N
0$|3
#'#D#D#F0K!K//0
0	044WgF	0J $ < <VW M
0$|3
#'#D#D#F0K!K//0
0
!% < <Wg N
0$|3
#'#D#D#F0K!K//0
0	0sFFc#K||f}tdd|gtdd|gtdd|tdd|gtdd|gtdd|gtdd|tdd|g|D]8}|D]1}|D]*}tdd|tdd|tdd|g,3:|D]K}|D]D}|D]=}|D]6}tdd|tdd|tdd|tdd|g8?FMyw)NrCrGrFr<)r-rrinterpsrinterp4s      rrz,ExhaustiveChannelTests._iter_use_action_sets.sG$
%1	
%1	
%1%1	
%1	
%1	
%1%1		G"
&G%eVW=%eVW=%eVW=
			G"
&G#*)%A)%A)%A)%A	
		sDD
c
#Kd}||f}dD]&}|rdnd}|D]}|D]}t|||g(dD]3}	dD],}
|D]%}|D]}t|	d|t|
d|g '.5yw)Nrtr7rJrIrHrGrFr)
r-rrendsrrgopr%rArecvopsendoprGrFs
             rrz.ExhaustiveChannelTests._iter_close_action_sets_sG$"	E"'WB!
C%b#v6
	/	F2
#D ')&&$?)&&$?
	sA+A-c#ZKdD]"}tdd|gtdd|g$yw)N)rDrLrKrCrGrFrrs  rrz3ExhaustiveChannelTests._iter_post_close_action_setsrsC0	FeVV4
eVV4
		s)+c6|D]}|j||yr)rq)r-fixrr@s    rrun_actionsz"ExhaustiveChannelTests.run_actions{s	)FOOC(	)rTric|j|j}|j|j|j|j
}|j
||jdk(rAt|j|j||j|}|j||ytj}t|j d|jdt#|jdt#|dt#|jd|d|d|dt%t&j)tj+|d	t-tj+|
}|j||y)NrrizB
                result = helpers.run_action(
                    z,
                    z!,
                    hideclosed=z6,
                    )
                channels.send(zF, result.pending.to_bytes(1, 'little'))
                channels.send(z2, b'X' if result.closed else b'')
                little)r[rY)rSrArUr%rKrLrr,rqrmr@rnrr7r)rr
rrWr
from_bytesrGr)r-rr@rjrAr%rprs        rrqz!ExhaustiveChannelTests.run_actionsR  )&&szz399ciiHV$;;& 

		%F
ff-??$Dvyy'WWI&--()*#YK #))_%&  *|,#f%#f%
#

"x}}T':HEHMM$/0F
ff-rc
#hKgd}|D]%\}}}dD]}dD]}t|||||'yw)N))rr%rL)r%rrL)rrrL)rrr)rDrKr}r)rw)r-rr%rKrLr}rAs       r
iter_fixturesz$ExhaustiveChannelTests.iter_fixturess\
%1	R FE57
R+RC-c65%QQR
R	Rs02c|rdnd}t||jd}|js|j||dy|j	t
j5|j||ddddy#1swYyxYw)NrJrIrDFri)r<rArrqrr7r8)r-rrgrrIs     r_closezExhaustiveChannelTests._closesv#]b#''62&&(OOC5O9""8#>#>?
>Uu=
>
>
>s"BB	Nc|||jdk(r |jtj5tj	|j
ddd|jtj5tj
|j
dddd|jtj5tj|j
ddd|jtj5tj|j
ddddyt|jdt|jdt|jdt|jdy#1swY<xYw#1swYxYw#1swYxYw#1swYyxYw)	NrrsTrfzn
                with helpers.expect_channel_closed():
                    channels.recv(cid)
                zw
                with helpers.expect_channel_closed():
                    channels.send(cid, b'spam')
                zo
                with helpers.expect_channel_closed():
                    channels.close(cid)
                z{
                with helpers.expect_channel_closed():
                    channels.close(cid, force=True)
                )
r,rr7r8rGrmrFrIrr
)r-rr%s   r_assert_closed_in_interpz/ExhaustiveChannelTests._assert_closed_in_interpsU>V[[F2""8#>#>?
'

cgg&
'""8#>#>?
0

cggw/
0""8#>#>?
(sww'
(""8#>#>?
4swwd3
4
4
vyy#

vyy#

vyy#

vyy#
+
'
'
0
0
(
(
4
4s/ F9!F F&"F2FF#&F/2F;c|j|jjt|jjD]!}t
j
|j#|j|dD]5}|j|}|jdk(r$|j||7|jd}|j||y)N)rDrKrfresh)rrnrYranger[r7rGrmrrr,)r-r_r%s    r_assert_closedz%ExhaustiveChannelTests._assert_closeds		(()syy(()	#AMM#''"	#%%c*'	7F((0F{{f$))#v6		7$$W-%%c62rc#Kd}|jD]}t|jD]}|dz
}|dkDry|r;|dz
dzdk(r
tt||djt	|nC|dz
dzdk(r
tddtd	dt
jj|||f|std
tyw)Nrr^rz({} actions) rQ.z---)rprintrr'rsysstdoutflush)r-verboseirrs     r_iter_close_testsz(ExhaustiveChannelTests._iter_close_testss
,,.	GG))+
&Qt8A{a'!S."7"7G"EFA{a'cr*#2&

(8(8(:go%
&e!	"	sCC&C&cLdt_|jD]\}}}y)NT)rwryrr-rrrs    r_skim_close_testsz(ExhaustiveChannelTests._skim_close_testss,$(!#557	OAsG	rcf|jD]\}}}|jdj|||5|j|j|j|||j
|d|j|ddd|jy#1swYxYw)N	{} {}  {}Frf	rrr'rr%rrrrrs    r
test_closez!ExhaustiveChannelTests.test_closes#557		OAsGk00CAB
)$$SZZ0  g.Cu-##C(

)
LLN		
)
)AB''B0	cf|jD]\}}}|jdj|||5|j|j|j|||j
|d|j|ddd|jy#1swYxYw)NrTrfrrs    rtest_force_closez'ExhaustiveChannelTests.test_force_closes#557		OAsGk00CAB
)$$SZZ0  g.Ct,##C(

)
LLN		
)
)rr)F)r0r1r2rurrrrrrqrrrrrrrrr9rrrrs`  +0Z/b&)59.@R>83 ,


rr__main__)%collectionsr
contextlibrtextwraprrrr[test.supportrtest.test__xxsubinterpretersrrr
import_moduler7rrrcontextmanagerr:r<rWrqrlr|TestCaser~rrr^rwr\rr0rr9rr<module>rsX"
&'=&&':; $-/	4!*]I6!L++/#J0CD/#fE:n.>?E&7;*!!H x   `,X`,Je	,8e	,Pb(bJn*%:%EGnb67{X{8{|	zHMMOr