
    vKgY                       % S SK Jr  S SKrS SKrS SKJrJr  S SKJrJ	r	J
r
JrJrJrJr  SSKJrJr  SSKJrJrJrJrJr  SSKJr  S	S
KJr  \(       a  S SKJr  S SKJrJ r   \" S5      r!\RD                  S:  a  S SK#J$r$  \" S\S9r%\" S\S9r&\
/ \	\\%\&4      4   r'S\(S'    " S S\\%\&4   5      r)\ S     SS jj5       r*      SS jr+      SS jr,      SS jr-g)     )annotationsN)contextmanagersuppress)TYPE_CHECKING	AwaitableCallable	GeneratorGenericTupleTypeVar   )CancelScope_core)AsyncResourceHalfCloseableStreamReceiveStream
SendStreamStream)aclose_forcefully   )assert_checkpoints)TracebackType)	ParamSpec	TypeAliasArgsT)      )BaseExceptionGroupRes1)boundRes2r   StreamMakerc                  B    \ rS rSrSS jrSS jr        S	S jrSrg)
_ForceCloseBoth%   c                "    Uu  U l         U l        g N_first_second)selfboths     [/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/trio/testing/_check_streams.py__init___ForceCloseBoth.__init__&   s    $(!T\    c                :   #    U R                   U R                  4$ 7fr'   r(   )r+   s    r-   
__aenter___ForceCloseBoth.__aenter__)   s     {{DLL((s   c                   #     [        U R                  5      I S h  vN   [        U R                  5      I S h  vN   g  N" N! [        U R                  5      I S h  vN    f = f7fr'   )r   r)   r*   )r+   exc_type	exc_value	tracebacks       r-   	__aexit___ForceCloseBoth.__aexit__,   sI     	2#DKK000#DLL111 11#DLL111sE   A&A ?A A&AA&A A&A#AA##A&r(   N)r,   tuple[Res1, Res2]returnNone)r;   r:   )r5   ztype[BaseException] | Noner6   zBaseException | Noner7   zTracebackType | Noner;   r<   )__name__
__module____qualname____firstlineno__r.   r2   r8   __static_attributes__ r0   r-   r$   r$   %   s7    ))	2,	2 (	2 (		2
 
	2r0   r$   c              #    #    Sn S v   [        SU  35      e! [         aS  nU(       d   S5       e[        UR                  5      S:X  d   e[	        UR                  S   U 5      (       d   e S nAg S nAfU  a    U(       a   S5       e g f = f7f)NTzexpected exception: z:caught exceptiongroup, but expected an unwrapped exceptionr   r   z0caught exception, but expected an exceptiongroup)AssertionErrorr   len
exceptions
isinstance)expected_excwrapped__tracebackhide__excs       r-   _assert_raisesrL   :   s     
 
D 3L>BCC  ;TTTw3>>"a'''#..+\:::: ONNN{7Os7   B B
B
A	A0+B0B
B	B

Bc           	     +  ^^^^^^^#    [        U " 5       I Sh  vN 5       ISh  vN u  mm[        T[        5      (       d   e[        T[        5      (       d   eS"U4S jjmS#S$U4S jjjmS%U4S jjmS&S jm[        R
                  " 5        ISh  vN nUR                  TS5        UR                  TS5        SSS5      ISh  vN   S'U4S jjn[        R
                  " 5        ISh  vN nUR                  U5        UR                  TS5        SSS5      ISh  vN   [        R
                  " 5        ISh  vN nUR                  T[        S	5      5        UR                  TS	5        SSS5      ISh  vN   [        R
                  " 5        ISh  vN nUR                  T[        S
5      5        UR                  TS
5        SSS5      ISh  vN   [        [        5         TR                  S5      I Sh  vN   SSS5        [        [        5         TR                  S5      I Sh  vN   SSS5        [        [        5         TR                  S5      I Sh  vN   SSS5        [        R
                  " 5        ISh  vN nUR                  TS5        T" 5       I Sh  vN S:X  d   eSSS5      ISh  vN   [        R
                  " 5        ISh  vN nUR                  TS5        T" S5      I Sh  vN S:X  d   eSSS5      ISh  vN   [        [        R                  SS9   [        R
                  " 5        ISh  vN nUR                  TS5        UR                  TS5        SSS5      ISh  vN   SSS5            S(U4S jjn[        R
                  " 5        ISh  vN nUR                  UUR                  5        UR                  TS5        SSS5      ISh  vN   S'U4S jjn[        R
                  " 5        ISh  vN nUR                  U5        UR                  TT5        SSS5      ISh  vN   [        [        R                  5         T" S5      I Sh  vN   SSS5        [        [        R                   5         T" S5      I Sh  vN   SSS5        T" T5      I Sh  vN   T" T5      I Sh  vN   T" T5      I Sh  vN   [        [        R                   5         T" S5      I Sh  vN   SSS5        [        [        R                   5         T" S5      I Sh  vN   SSS5        [        [        R                   5         [#        5          TR%                  5       I Sh  vN   SSS5        SSS5        T" T5      I Sh  vN   T" T5      I Sh  vN   SSS5      ISh  vN   [        U " 5       I Sh  vN 5       ISh  vN u  mmS'UUU4S jjnS'UUU4S jjn[        R
                  " 5        ISh  vN nUR                  U5        UR                  U5        SSS5      ISh  vN   SSS5      ISh  vN   [        U " 5       I Sh  vN 5       ISh  vN u  mm['        T5      I Sh  vN   [        [        R                  5          T" S5      I Sh  vN   M   GN GN GN1 GN ! , ISh  vN  (       d  f       GN= f GN GN! , ISh  vN  (       d  f       GN= f GN GN! , ISh  vN  (       d  f       GN= f GN GNT! , ISh  vN  (       d  f       GNj= f GNI! , (       d  f       GNN= f GN-! , (       d  f       GN2= f GN! , (       d  f       GN= f GN  GN GN! , ISh  vN  (       d  f       GN= f GN GN GN! , ISh  vN  (       d  f       GN= f GN GNS! , ISh  vN  (       d  f       GNi= f! , (       d  f       GNs= f GNQ GN! , ISh  vN  (       d  f       GN,= f GN GN! , ISh  vN  (       d  f       GN= f GN! , (       d  f       GN= f GN! , (       d  f       GN= f GN GN GN GNq! , (       d  f       GNv= f GNT! , (       d  f       GNY= f GN$! , (       d  f       GN)= f! , (       d  f       GN3= f GN+ GN GN! , ISh  vN  (       d  f       GN'= f GN GN GN GN! , ISh  vN  (       d  f       GN= f GN! , ISh  vN  (       d  f       GN= f GN GN GN GN! , (       d  f       O= f[        [        R                   5         T" S5      I Sh  vN    SSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U " 5       I Sh  vN  5       ISh  vN  u  mm['        T5      I Sh  vN    [        [        R                   5         T" S5      I Sh  vN    SSS5        O! , (       d  f       O= f[)        [        R                  5         T" S5      I Sh  vN    SSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U " 5       I Sh  vN  5       ISh  vN  u  mm[        R*                  " 5        nUR-                  5         TR/                  5       I Sh  vN    SSS5        O! , (       d  f       O= f[        R*                  " 5        nUR-                  5         TR/                  5       I Sh  vN    SSS5        O! , (       d  f       O= f[        [        R                   5         T" S5      I Sh  vN    SSS5        O! , (       d  f       O= f[        [        R                   5         T" S5      I Sh  vN    SSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U " 5       I Sh  vN  5       ISh  vN  u  mm        S)S jn	[        R*                  " 5        nUR-                  5         [        R
                  " 5        ISh  vN  nUR                  U	TS5        UR                  U	TS5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5        O! , (       d  f       O= f[        R
                  " 5        ISh  vN  nUR                  TT5        UR                  TT5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U " 5       I Sh  vN  5       ISh  vN  u  mmU4S jn
[        R
                  " 5        ISh  vN  nUR                  U
5        [        R0                  " 5       I Sh  vN    ['        T5      I Sh  vN    SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fUGbT  [        U" 5       I Sh  vN  5       ISh  vN  u  mm/ mS*UU4S jjnS'UU4S jjn[        R
                  " 5        ISh  vN  nUR                  XR                  5        [        R0                  " 5       I Sh  vN    UR                  U5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fT/ SQ:X  d   eSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U" 5       I Sh  vN  5       ISh  vN  u  mm[        [        R                  SS9   [        R
                  " 5        ISh  vN  nUR                  TR$                  5        UR                  TR$                  5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5        O! , (       d  f       O= f[        [        R                  SS9   [        R
                  " 5        ISh  vN  nUR                  TR$                  5        UR                  TR2                  S5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U" 5       I Sh  vN  5       ISh  vN  u  mm[        [        R                  SS9   [        R
                  " 5        ISh  vN  nUR                  TR2                  S5        UR                  TR2                  S5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U" 5       I Sh  vN  5       ISh  vN  u  mmS'U4S jjnS'U4S jjn[        R
                  " 5        ISh  vN  nUR                  U5        UR                  U5        SSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U" 5       I Sh  vN  5       ISh  vN  u  mm['        T5      I Sh  vN     [#        5          TR%                  5       I Sh  vN    SSS5        O+! , (       d  f       O= f! [        R                   a     Of = fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fS+S  jn[        U" 5       I Sh  vN  5       ISh  vN  u  mm[        R
                  " 5        ISh  vN  nUR                  UT5        [        [        R                   5         TR3                  S!5      I Sh  vN    SSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= f[        U" 5       I Sh  vN  5       ISh  vN  u  mm[        R
                  " 5        ISh  vN  nUR                  UT5        [        [        R                   5         TR%                  5       I Sh  vN    SSS5        O! , (       d  f       O= fSSS5      ISh  vN    O! , ISh  vN  (       d  f       O= fSSS5      ISh  vN    g! , ISh  vN  (       d  f       g= fg7f),a  Perform a number of generic tests on a custom one-way stream
implementation.

Args:
  stream_maker: An async (!) function which returns a connected
      (:class:`~trio.abc.SendStream`, :class:`~trio.abc.ReceiveStream`)
      pair.
  clogged_stream_maker: Either None, or an async function similar to
      stream_maker, but with the extra property that the returned stream
      is in a state where ``send_all`` and
      ``wait_send_all_might_not_block`` will block until ``receive_some``
      has been called. This allows for more thorough testing of some edge
      cases, especially around ``wait_send_all_might_not_block``.

Raises:
  AssertionError: if a test fails.

Nc                   >#    [        5          TR                  U 5      I S h  vN b   e S S S 5        g  N! , (       d  f       g = f7fr'   )r   send_all)datass    r-   do_send_all)check_one_way_stream.<locals>.do_send_allg   s7     #%ZZ--555 &%- &%s%   A757	A7
AAc                   >#    [        5          TR                  U 5      I S h  vN sS S S 5        $  N! , (       d  f       g = f7fr'   )r   receive_some)	max_bytesrs    r-   do_receive_some-check_one_way_stream.<locals>.do_receive_somek   s.     #%^^I66 &%6 &%s$   A313
A3
AAc                >   >#    T" S5      I S h  vN U :X  d   eg  N7fNr   rB   )expectedrX   s    r-   checked_receive_1/check_one_way_stream.<locals>.checked_receive_1o   s     (++x777+s   c                   #    [        5          U R                  5       I S h  vN   S S S 5        g  N! , (       d  f       g = f7fr'   )r   aclose)resources    r-   	do_aclose'check_one_way_stream.<locals>.do_acloser   s.     #%oo''' &%' &%s#   A1/1	A1
?A   xc                 V   >#    T " S5      I S h  vN   T " S5      I S h  vN   g  N N7f)Nr0      yrB   rR   s   r-   send_empty_then_y/check_one_way_stream.<locals>.send_empty_then_y{   s,      c"""d### ##   )%)'))rf      1   2r   g      ?TrI   r   c                   >#    [        5          TR                  5       I S h  vN   S S S 5        U R                  5         g  N! , (       d  f       N!= f7fr'   )r   wait_send_all_might_not_blockcancel)scoperQ   s    r-   *simple_check_wait_send_all_might_not_blockHcheck_one_way_stream.<locals>.simple_check_wait_send_all_might_not_block   s;      $%55777 &LLN 8 &%s+   AAA AA A
AAc                    >#    [        [        R                  5          T " S5      I S h  vN   M   N! , (       d  f       g = f7f)Nd   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)rL   r   BrokenResourceErrorrg   s   r-   expect_broken_stream_on_send:check_one_way_stream.<locals>.expect_broken_stream_on_send   s5      9 9:%j111 1 ;:s   A313
AArv   i   r0   c                 V   >#    T" S5      I S h  vN   T " T5      I S h  vN   g  N N7f)Nrf   rB   )rb   rR   rQ   s   r-   send_then_close-check_one_way_stream.<locals>.send_then_close   s)     d###A, $rj   c                    >#    [         R                  " 5       I S h  vN   T " S5      I S h  vN   T " S5      I S h  vN   T" T5      I S h  vN   g  N5 N' N N7f)Nrf   r0   )r   wait_all_tasks_blocked)r]   rb   rW   s   r-   receive_send_then_close5check_one_way_stream.<locals>.receive_send_then_close   sQ     
 ..000#D)))#C(((A, 1)(sA   AAAAAAAAAAAAs   123c                   #    [        [        R                  5         U " U0 UD6I S h  vN   S S S 5        g  N! , (       d  f       g = f7fr'   )rL   r   	Cancelled)afnargskwargss      r-   expect_cancelled.check_one_way_stream.<locals>.expect_cancelled'  s9     
  04*6*** 10* 10s%   A	868	A	8
AA	c                    >#    [        [        R                  5         T R                  S5      I S h  vN   S S S 5        g  N! , (       d  f       g = f7f)N
   )rL   r   ClosedResourceErrorrU   rW   s   r-   receive_expecting_closed6check_one_way_stream.<locals>.receive_expecting_closed=  s9      9 9:nnR((( ;:( ;:s+   AAA A	A A
AAc                   >#    TR                  S5        [        5          TR                  5       I S h  vN   S S S 5        TR                  S5        U R                  5         g  N.! , (       d  f       N2= f7f)Nwaiter sleepingwaiter wokeup)appendr   rp   rq   )cancel_scoperecordrQ   s    r-   waiter$check_one_way_stream.<locals>.waiterK  sU     /0')99;;; *o.##% < *)s+   A5A$A"A$*A5"A$$
A2.A5c                    >#    [         R                  " 5       I S h  vN   TR                  S5         T R                  S5      I S h  vN   M   N1 N7f)Nreceiver startingiA  )r   r~   r   rU   )rW   r   s   r-   receiver&check_one_way_stream.<locals>.receiverR  sI     2244412..///  5 0s!   AA*AAAA)r   r   r   c                    >#     [        5          T R                  5       I S h  vN   S S S 5        g  N! , (       d  f       g = f! [        R                   a     g f = f7fr'   )r   rp   r   rw   rQ   s   r-   sender$check_one_way_stream.<locals>.sender  sM     +-==??? .-? .-00 sR   A
A 313A A3
AA  AA AAAAc                 v   >#    [         R                  " 5       I S h  vN   [        T 5      I S h  vN   g  N N7fr'   r   r~   r   r   s   r-   r   r     s.     22444'*** 5*s   959799c                t   #    [         R                  " 5       I S h  vN   [        U 5      I S h  vN   g  N N7fr'   r   r   s    r-   
close_soon(check_one_way_stream.<locals>.close_soon  s-     ..000#A&&& 1&s   848688s   xyzzy)rP   bytes | bytearray | memoryviewr;   r<   r'   )rV   z
int | Noner;   bytes | bytearray)r\   bytesr;   r<   )ra   r   r;   r<   r;   r<   )rr   r   r;   r<   )r   z"Callable[ArgsT, Awaitable[object]]r   z
ArgsT.argsr   zArgsT.kwargsr;   r<   )r   r   r;   r<   )rQ   r   r;   r<   )r$   rG   r   r   r   open_nursery
start_soon	bytearray
memoryviewrL   
ValueErrorrU   	TypeErrorBusyResourceErrorr   rw   r   r   rp   r   r   r   rq   r`   r~   rO   )stream_makerclogged_stream_makernurseryrh   rs   rx   r{   r   rr   r   r   r   r   r   r   r]   rb   rX   rR   rW   r   rQ   s                  @@@@@@@r-   check_one_way_streamr   M   sr    , \^344A!Z((((!]++++	6	7 	7	8	(
 %%''7{D10$7 ('	$ %%''7010$7 (' %%''7{IdO<0$7 (' %%''7{Jt,<=0$7 ('
 J'..$$$ (J'..### (I&..%%% ' %%''7{D1(**d222 (' %%''7{D1(..$666 (' E33TB))++w""?A6""?A6 ,+ C			 %%''7:$$ 2 ('	2
 %%''7;<y!, ('
 E556j))) 7 E556!$''' 7 ll l E556j))) 7 E556c""" 7 E556#%55777 & 7
 ll{ 54~ \^344A	 		 	 %%''7/67 ('! 54( \^344A"""E556!*--- o  44( (''' (''' (''' (''' % (' $ (' & '& (* (''' (. ('''
 ,+++ CB" (''' (''' * 76
 ( 76 	 	 * 76
 # 76 8 &% 76
 	{ 5444~  44  ('''! 5444(  44" . 76 E556!$''' 766 544444 \^3344A"""E556f%%% 766 e//0#C((( 100 544444 \^3344A ELLN((* !    ELLN((* !   E556f%%% 766 E556!$''' 766 5444440 \^3344A	+3	+	+ #	+ 		+  ELLN))++w""#3[$G""#3_aH ,+++++ !   %%''7y!,y!, ('''''! 544444, \^3344A	) %%''778..000#A&&& (''''' 544444 '")=)?#?#?@@FQ "F& &0 0 ))++w""6+?+?@22444""8, ,+++++
     - A@@@@@8 #)=)?#?#?@@FQ 7 7F --//7&&q'F'FG&&q'F'FG 0///// GFF   7 7F --//7&&q'F'FG&&qzz6: 0///// GFF A@@@@@  #)=)?#?#?@@FQ   7 7F --//7&&qzz6:&&qzz6: 0///// GFF A@@@@@ #)=)?#?#?@@FQ+ ))++w""6*""8, ,+++++ A@@@@@$ #)=)?#?#?@@FQ#A&&&')99;;; *)),,  A@@@@@	' #)=)?#?#?@@FQ))++w"":q1#E$=$=>**X... ?>> ,+++++ A@@@@@ #)=)?#?#?@@FQ))++w"":q1#E$=$=>99;;; ?>> ,+++++ A@@@@@{ (s  AW<Z?AW<[AW<A*c[c%[=c[	%c.[&/c2$[,c![)"c?\ c.\1c<\
=c\(c.\.c\+c+] ]	]c]!1]2]!6c]6"]3#]6'!c^	c^)^*
^4c?^ c^,c!^5?^/ 
^5
c^2c2_1_
_1%_5_1 __1-c2`3c6/`	%c0`1%c`$c$`*>c	`'
c'a3a4a8!ca%a&a*c=a/>ca2ca5c;a;a8a;!c-b9b:b>!cb7*b%>b"
?b%b7cc	c.c/c3AW<>c?AW<c-AW<c0 AW<#1dc3d#c9;dc6dAW<dAW<*d2+AW<7d58AW<;f&d8f&+d>8d;9d>?AW<AW<cc[#	[[#		c)c,\	2[53\	?	c
c\%	\\%	 	c+c.]	4\75]	c	]
]	c]!!
]0	+c3]66
^	 	c^c^)	^^)	$	c/^52c5_	;^><_	c_1_1_.__.)_11
` 	;	cc	`!	``!		c'c*a	0`31a	=ca
a	ca
a,	'	c2c5c8a;;
b
	cb
b	c"b%%
b4/b77
c		ccAW<c*cc*%	AW<0AW<3d6d9d	?d d	dAW<d/d d/*	AW<5AW<8f&;d>>
e	 f&(f4e75f:	f&
f	f&AW<f" AW<&f=,f/-f=9AW<gAW<g AW<"j4g75jh.h" h.%	j.
h<	8 ji3$i'%i3*	j3
j	=jAW<jAW<j-jj-)AW<?k AW<kAW<p$+$lll	p$
l,	(p$$m7(m+)m7.	p$7
n	 p$!n<-n0.n<3	p$<
o
	 p$&p2o53p8	p$
p	p$AW<p AW<$p;*p-+p;7AW<qAW<qAW< &v#*t0r3
1t5's.t's*(t.t4s75tt	v#
t	 v#;t><v# %u7%v#0u31v#7v	=v >v	
v#AW<vAW<#v:)v,*v:6AW<wAW<wAW<#z	xz	*y1x42yyyz	yz	y4	#y&$y4	0z	7AW<zAW<	z zz AW<6z97AW<{AW<	1~:{=;~?4}3|64}
~}~}3	"}%#}3	/~ AW<~AW<~)~~)%AW<;~><AW<	
AW<AE*AA5@A@
@AA5@	7AAA AA5AAAAAA5AAA)AAAAAA)A%AA5A,	AEA5
AB	A?AEBAD*B8AB;
B9AD*B=8ADC5AD*D ADDAD*DADDADDADDAD*D!	AED*
AD8	D4AED;AW<EAE	EAW<EAE$EAEEAE$E AW<E6AE9E7AW<FAFFAW<F	AIF%AH2F?AG
G AH2G9AHG=AH2HAHH	AH2HAH&HAHHAH&H"AH2H)	AIH2
AI 	H<AIIAW<IAIIAW<IAI,IAIIAI,I(AW<I>AJI?AW<JAJJAW<J-AL$J>AKJ?AL$K#AK8K&AL$K1AK4K2AL$K8AL	K>ALK?AL	LAL$LAW<LAL LAW<L$AL;L*AL-L+AL;L7AW<MAMMAW<MAMMAW<M AO#M2AM5M3AO#M9
AN7NAN&NANNAN&NAN7N%AO#N&
AN4	N0AN7N3AO#N4AN7N7AOOAO#OAOOAO#OAW<OAOOAW<O#AO:O)AO,O*AO:O6AW<PAPPAW<PAP"P AW<P$AS%QAQQAS%Q,AR9Q2ARRAR

RARR	AR9R
AR$R AR9R'AS%R2AR5R3AS%R9AS	R?ASS AS	SAS%SAW<SAS!SAW<S%AS<S+AS.S,AS<S8AW<TATTAW<TATTAW<T!AW!T>AUT?AW!U,AV5U/AVVAV
VAVV		AV5V
AV VAV5V#AW!V.AV1V/AW!V5AW	V;AV>V<AW	WAW!WAW<WAWWAW<W!AW8W'AW*W(AW8W4AW<c           
       ^ ^^^#    [        T T5      I Sh  vN   SU 4S jjnTb	  SU4S jjnOSn[        X#5      I Sh  vN   [        T " 5       I Sh  vN 5       ISh  vN u  nm[        U[        5      (       d   e[        T[        5      (       d   eSnSm[        R
                  " S5      nUR                  SU-  5      nUR                  US5      n        SU4S	 jjn	SU4S
 jjn
[        R                  " 5        ISh  vN nUR                  XUS5        UR                  U	TUSSS2   S5        UR                  XUSSS2   S5        UR                  U
TUS5        SSS5      ISh  vN   SU4S jjn[        R                  " 5        ISh  vN nUR                  U5        UR                  UR                  5        SSS5      ISh  vN   SSS5      ISh  vN   g GN GN GN GN N N! , ISh  vN  (       d  f       N= f N{ NA! , ISh  vN  (       d  f       NV= f NM! , ISh  vN  (       d  f       g= f7f)u  Perform a number of generic tests on a custom two-way stream
implementation.

This is similar to :func:`check_one_way_stream`, except that the maker
functions are expected to return objects implementing the
:class:`~trio.abc.Stream` interface.

This function tests a *superset* of what :func:`check_one_way_stream`
checks – if you call this, then you don't need to also call
:func:`check_one_way_stream`.

Nc                 :   >#    T " 5       I S h  vN S S S2   $  N
7fNrm   rB   )r   s   r-   flipped_stream_maker2check_two_way_stream.<locals>.flipped_stream_maker  s     "n$dd++$   c                 :   >#    T " 5       I S h  vN S S S2   $  N
7fr   rB   )r   s   r-   flipped_clogged_stream_maker:check_two_way_stream.<locals>.flipped_clogged_stream_maker  s     .00$B$770r   i   i @  r      littlec                   >#    [         R                  " U5      n[        U5      nU(       a<  UR                  ST5      nU R	                  US U 5      I S h  vN   XES  nU(       a  M;  g g  N7fr[   )randomRandomr   randintrO   )rQ   rP   seedrW   m
chunk_sizeCHUNK_SIZE_MAXs         r-   r   $check_two_way_stream.<locals>.sender  s^     
 d#A4 AYYq.9
jj;J000kN !0s   AA+A)A+'A+c                0  >#    [         R                  " U5      n[        5       n[        U5      [        U5      :  aP  U R	                  UR                  ST5      5      I S h  vN nU(       d   eXE-  n[        U5      [        U5      :  a  MP  XA:X  d   eg  N37fr[   )r   r   r   rE   rU   r   )rQ   rP   r   rW   gotchunkr   s         r-   r   &check_two_way_stream.<locals>.receiver  sy     d#A+Cc(SY&nnQYYq.-IJJu c(SY& ;; Ks   AB B!)B	Brm   r   r   r   c                    >#    T R                  S5      I S h  vN S:X  d   eT R                  5       I S h  vN   g  N# N7f)Nr   r0   )rU   r`   )s2s   r-   expect_receive_some_empty7check_two_way_stream.<locals>.expect_receive_some_empty  s7     ,,333))+ -s   A <A >A A )r;   ztuple[Stream, Stream])rQ   r   rP   r   r   intr;   r<   )rQ   r   rP   r   r   r   r;   r<   r   )r   r$   rG   r   r   r   getrandbitsto_bytesr   r   r   r`   )r   r   r   r   s1DUPLEX_TEST_SIZErW   i	test_datar   r   r   r   r   r   s   ``           @@r-   check_two_way_streamr     s      |-A
BBB,
 '	8 	8 (,$
3
RRR\^344R"f%%%%"f%%%% !MM!MM!../JJ/:	
	#
	#0
	# 
	# 	
	#	 %%''7v9a8vr9TrT?A>xYtt_a@xY:	 ('	 %%''789ryy) ('W 544! C S34B (''' ('''W 5444s  IG)(IG, IG/I G2!I$B#H3G5H3AG9&H31G72%H3HH3-HH3HH3I#H1$I,I/I2I5H37H39H	?H H	H3H3H.	H H.	*H31I3I
9H<:I
Ic           	      	  #    [        X5      I Sh  vN   [        U " 5       I Sh  vN 5       ISh  vN u  p#[        U[        5      (       d   e[        U[        5      (       d   eSS jnS	S jn[        R
                  " 5        ISh  vN nUR                  XB5        UR                  XS5        SSS5      ISh  vN   [        [        R                  5         UR                  S5      I Sh  vN   SSS5        [        5          UR                  5       I Sh  vN   SSS5        [        R
                  " 5        ISh  vN nUR                  XC5        UR                  XR5        SSS5      ISh  vN   SSS5      ISh  vN   UGb  [        U" 5       I Sh  vN 5       ISh  vN u  p#[        [        R                  SS9   [        R
                  " 5        ISh  vN nUR                  UR                  S5        [        R                  " 5       I Sh  vN   UR                  UR                  5        SSS5      ISh  vN   SSS5        SSS5      ISh  vN   [        U" 5       I Sh  vN 5       ISh  vN u  p#[        [        R                  SS9   [        R
                  " 5        ISh  vN nUR                  UR                  5        [        R                  " 5       I Sh  vN   UR                  UR                  5        SSS5      ISh  vN   SSS5        SSS5      ISh  vN   gg GN' GN GN GN GN! , ISh  vN  (       d  f       GN= f GNs! , (       d  f       GNx= f GN]! , (       d  f       GNb= f GNL GN! , ISh  vN  (       d  f       GN3= f GN+! , ISh  vN  (       d  f       GNA= f GN1 GN' GN GN GN! , ISh  vN  (       d  f       GN= f! , (       d  f       GN= f GN! , ISh  vN  (       d  f       GN= f GN GN GNu GN@ GN! , ISh  vN  (       d  f       GN.= f! , (       d  f       GN8= f GN0! , ISh  vN  (       d  f       g= f7f)
u  Perform a number of generic tests on a custom half-closeable stream
implementation.

This is similar to :func:`check_two_way_stream`, except that the maker
functions are expected to return objects that implement the
:class:`~trio.abc.HalfCloseableStream` interface.

This function tests a *superset* of what :func:`check_two_way_stream`
checks – if you call this, then you don't need to also call
:func:`check_two_way_stream`.

Nc                   #    U R                  S5      I S h  vN   [        5          U R                  5       I S h  vN   S S S 5        g  N0 N! , (       d  f       g = f7f)Nrd   )rO   r   send_eofr   s    r-   send_x_then_eof4check_half_closeable_stream.<locals>.send_x_then_eof  sD     **T"""#%jjl"" &% #" &%s5   AAAAA
A
A
A
AAc                   #    [         R                  " 5       I S h  vN   U R                  S5      I S h  vN S:X  d   eU R                  S5      I S h  vN S:X  d   eg  NC N, N7f)Nr   rd   r0   )r   r~   rU   r   s    r-   expect_x_then_eof6check_half_closeable_stream.<locals>.expect_x_then_eof  sV     ..000++t333++s222 1++s1   A%AA%A!A%A#A%!A%#A%rf   Trn   rd   )rQ   r   r;   r<   )rW   r   r;   r<   )r   r$   rG   r   r   r   r   rL   r   rO   r   r   r   r~   rp   )r   r   r   r   r   r   r   s          r-   check_half_closeable_streamr     s       |
BBB\^344"12222"12222	#
	3
 %%''7305 ('
 E556++d### 7  !++- " %%''7305 ('7 54> '")=)?#?@@HR 7 7F --//7&&r{{D966888&&r{{3 0/ G A@ #)=)?#?@@HR   7 7F --//7&&r'G'GH66888&&r{{3 0/ G A@@ (C C34 (''' $ 76
   "! ('''7 5444@ $@@ 08 0/// GF A@@@ $@@ 08 0/// GF A@@@s  Q>L8Q>L;Q>L>Q>AN0
MN0#M1N0<M=N0M%/M"0M%4N0M:M7M:!N0 NN0#N'N02N3N07Q>N-Q>OQ>'O(Q>+P
O5 O
!O5$5OO
O9O5OO5	P
Q>PQ>0P%1Q>=P(>Q>Q$Q6P+
7Q:4P4.P.
/P4QP1QQ$&Q>1Q!2Q>;Q>>Q>N0N0M	MM	N0"M%%
M4	/N07M::
N			N0N0N*	NN*	%N0-Q>0O6N97O	Q>Q>O5OO5O2 O#!O2-O55
P	?P
Q>
P"PP"	Q>(Q>+Q.P41Q4Q:P=;QQ
Q	Q$!Q>$Q;*Q-+Q;7Q>)F)rH   ztype[BaseException]rI   boolr;   zGenerator[None, None, None])r   z&StreamMaker[SendStream, ReceiveStream]r   z-StreamMaker[SendStream, ReceiveStream] | Noner;   r<   )r   zStreamMaker[Stream, Stream]r   z"StreamMaker[Stream, Stream] | Noner;   r<   )r   z5StreamMaker[HalfCloseableStream, HalfCloseableStream]r   z<StreamMaker[HalfCloseableStream, HalfCloseableStream] | Noner;   r<   ).
__future__r   r   sys
contextlibr   r   typingr   r   r   r	   r
   r   r    r   r   _abcr   r   r   r   r   _highlevel_genericr   _checkpointsr   typesr   typing_extensionsr   r   r   version_infoexceptiongroupr   r   r!   r"   __annotations__r$   rL   r   r   r   rB   r0   r-   <module>r      sG   "  
 /   " X X 2 ,#6gEg1v]+v]+!"idDj0A&B"BCY C2gdDj) 2*  D%DD !D D$[<8[<G[< 
[<|
M*-M*<M* 
M*`A4GA4VA4 
A4r0   