HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_asyncio/__pycache__/test_streams.cpython-310.opt-1.pyc
o

�i��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZzddlZWne
y?dZYnwddlZddlmZdd�ZGdd	�d	ej�Zed
krae��dSdS)zTests for streams.py.�N)�mock)�
socket_helper)�utilscCst�d�dS�N)�asyncioZset_event_loop_policy�rr�;/usr/local/lib/python3.10/test/test_asyncio/test_streams.py�tearDownModulesr	cs�eZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zej	d
d��Z
dd
�Ze�
edud�dd��Zej	e�
edud�dd���Zdd�Zdd�Zej	dd��Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<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�Z0dTdU�Z1dVdW�Z2dXdY�Z3dZd[�Z4ej	d\d]��Z5e�
e6j7d^kd_�d`da��Z8dbdc�Z9ddde�Z:dfdg�Z;dhdi�Z<djdk�Z=dldm�Z>dndo�Z?dpdq�Z@drds�ZAdtdu�ZBdvdw�ZCdxdy�ZDdzd{�ZEd|d}�ZFd~d�ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZN�ZOS)��StreamTestssline1
line2
line3
cs$t���t��|_|�|j�dSr)�super�setUprZnew_event_loop�loop�set_event_loop��self��	__class__rrrs

zStreamTests.setUpcs,t�|j�|j��t��t���dSr)�
test_utils�run_brieflyr
�close�gcZcollectr�tearDownrrrrr#s
zStreamTests.tearDowncs�g�|j��fdd��|j�|�\}}|�d�|��}|j�|�}|�|d�|��}|j�|�}|�|�d��|�	�|��g�dS)Nc�
��|�Sr��append�r
�ctx��messagesrr�<lambda>-�
z7StreamTests._basetest_open_connection.<locals>.<lambda>�GET / HTTP/1.0

�HTTP/1.0 200 OK
�

Test message)
r
�set_exception_handler�run_until_complete�write�readline�assertEqual�read�
assertTrue�endswithr�r�open_connection_fut�reader�writer�f�datarrr�_basetest_open_connection+s
z%StreamTests._basetest_open_connectioncC�Dt���}tj|j�}|�|�Wd�dS1swYdSr)r�run_test_serverr�open_connection�addressr2�r�httpdZconn_futrrr�test_open_connection9�
"�z StreamTests.test_open_connectioncC�Dt���}t�|j�}|�|�Wd�dS1swYdSr)r�run_test_unix_serverr�open_unix_connectionr6r2r7rrr�test_open_unix_connection>�
"�z%StreamTests.test_open_unix_connectionc	s�g�|j��fdd��z|j�|�\}}Wt�d�nt�d�w|�d�|��}|j�|�}|�|�d��|�	�|�
�g�dS)NcrrrrrrrrFr zCStreamTests._basetest_open_connection_no_loop_ssl.<locals>.<lambda>r!r#)r
r$r%rrr&r)r*r+rr(r,rrr�%_basetest_open_connection_no_loop_sslDs
z1StreamTests._basetest_open_connection_no_loop_sslNz
No ssl modulecCsRtjdd��}tj|jdt��i�}|�|�Wd�dS1s"wYdS)NT�Zuse_ssl�ssl)rr4rr5r6�dummy_ssl_contextr@r7rrr� test_open_connection_no_loop_sslSs��"�z,StreamTests.test_open_connection_no_loop_sslcCsRtjdd��}tj|jt��dd�}|�|�Wd�dS1s"wYdS)NTrA�)rBZserver_hostname)rr<rr=r6rCr@r7rrr�%test_open_unix_connection_no_loop_ssl\s�"�z1StreamTests.test_open_unix_connection_no_loop_sslcs�g�|j��fdd��|j�|�\}}|j�t��|��}|�t��|j�|�Wd�n1s5wY|��t	�
|j�|��g�dS)Ncrrrrrrrrjr z=StreamTests._basetest_open_connection_error.<locals>.<lambda>)r
r$r%Z	_protocolZconnection_lost�ZeroDivisionErrorr)�assertRaisesrrrr()rr-r.r/r0rrr�_basetest_open_connection_errorhs�z+StreamTests._basetest_open_connection_errorcCr3r)rr4rr5r6rIr7rrr�test_open_connection_errortr:z&StreamTests.test_open_connection_errorcCr;r)rr<rr=r6rIr7rrr�test_open_unix_connection_erroryr?z+StreamTests.test_open_unix_connection_errorcCs*tj|jd�}|�d�|�d|j�dS�N�r
�)r�StreamReaderr
�	feed_datar(�_buffer�r�streamrrr�test_feed_empty_datas
z StreamTests.test_feed_empty_datacCs.tj|jd�}|�|j�|�|j|j�dS�NrM)rrOr
rP�DATAr(rQrRrrr�test_feed_nonempty_data�sz#StreamTests.test_feed_nonempty_datacCsLtj|jd�}|�|j�|j�|�d��}|�d|�|�|j|j�dS)NrMrrN)	rrOr
rPrVr%r)r(rQ�rrSr1rrr�test_read_zero�s
zStreamTests.test_read_zerocsftj�jd���j���d��}��fdd�}�j�|��j�|�}���j|���d�j	�dS)NrM�cs���j�dSr�rPrVrrRrr�cb�sz!StreamTests.test_read.<locals>.cbrN)
rrOr
�create_taskr)�	call_soonr%r(rVrQ�r�	read_taskr\r1rrRr�	test_read�szStreamTests.test_readcCsRtj|jd�}|�d�|�d�|j�|�d��}|�d|�|�d|j�dS)NrMsline1sline2��rrOr
rPr%r)r(rQrXrrr�test_read_line_breaks�s

z!StreamTests.test_read_line_breakscsbtj|jd��|j���d��}�fdd�}|j�|�|j�|�}|�d|�|�d�j�dS)NrMics���dSr)�feed_eofr�rSrrr\�sz%StreamTests.test_read_eof.<locals>.cbrN�	rrOr
r]r)r^r%r(rQr_rrfr�
test_read_eof�szStreamTests.test_read_eofcsbtj|jd��|j���d��}�fdd�}|j�|�|j�|�}|�d|�|�d�j�dS)NrM���cs ��d���d����dS)Nschunk1
�chunk2�rPrerrfrrr\�s

z+StreamTests.test_read_until_eof.<locals>.cbs
chunk1
chunk2rNrgr_rrfr�test_read_until_eof�szStreamTests.test_read_until_eofcC�^tj|jd�}|�d�|j�|�d��}|�d|�|�t��|�	t|jj|�d��dS�NrM�line
��li)
rrOr
rPr%r)r(�
set_exception�
ValueErrorrHrXrrr�test_read_exception��
�zStreamTests.test_read_exceptioncCs~|�td��tjd|jd�Wd�n1swY|�td��tjd|jd�Wd�dS1s8wYdS)NZimitr��limitr
ri)�assertRaisesRegexrsrrOr
rrrr�test_invalid_limit�s�"�zStreamTests.test_invalid_limitcC�Jtjd|jd�}|�d�|j�|�d��}|�d|�|�d|j�dS�N�rvschunkrbrNrcrXrrr�test_read_limit��

zStreamTests.test_read_limitcsjtj|jd����d�|j�����}�fdd�}|j�|�|j�|�}|�d|�|�d�j	�dS)NrMschunk1 cs"��d���d���d�dS)Nschunk2 schunk3 s
 chunk4)rPrrfrrr\�s

z%StreamTests.test_readline.<locals>.cbschunk1 chunk2 chunk3 
s chunk4)
rrOr
rPr]r'r^r%r(rQ)rr`r\�linerrfr�
test_readline�s
zStreamTests.test_readlinecCs�tjd|jd�}|�d�|�d�|�t|jj|���|�d|j	�tjd|jd�}|�d�|�d�|�d�|�t|jj|���|�d|j	�dS)Nr|rvrqs
ne1
line2
sline2
sne1rN)
rrOr
rPrHrsr%r'r(rQrRrrr�&test_readline_limit_with_existing_data�s

�


�z2StreamTests.test_readline_limit_with_existing_datacCs�tj|jd�}|�|���|�d�|�|���|j�|���|�|���|�d�|��|j�|���|�	|���dS)NrMs
some data
)
rrOr
�assertFalse�at_eofrPr%r'rer*rRrrr�test_at_eofs

zStreamTests.test_at_eofcs�tjd|jd���fdd�}|j�|�|�t|jj����|�d�j	�tjd|jd���fdd�}|j�|�|�t|jj����|�d�j	�tjd|jd����
d�|j�����}|�d|�|�d�j	���
d	�|�t��}|j�����Wd�n1s�wY|�d�j	���
d
�|�t��}|j�����Wd�n1s�wY|�d�j	�dS)N�rvc�*��d���d���d����dS)N�chunk1rj�chunk3
rkrrfrrr\"�


z+StreamTests.test_readline_limit.<locals>.cbrNcr�)Nr�schunk2
r�rkrrfrrr\0r�r�s1234567
s	12345678
s12345678)rrOr
r^rHrsr%r'r(rQrP)rr\r�cmrrfr�test_readline_limits:��

�
�zStreamTests.test_readline_limitcCsdtj|jd�}|�|jdd��|�|jdd��|j�|���}|�d|�|�d|j�dS)NrM�sline1
sline2
line3
)	rrOr
rPrVr%r'r(rQ�rrSrrrr�test_readline_nolimit_nowaitLsz(StreamTests.test_readline_nolimit_nowaitcCs@tj|jd�}|�d�|��|j�|���}|�d|�dS)NrMs	some data)rrOr
rPrer%r'r(r�rrr�test_readline_eofXs

zStreamTests.test_readline_eofcCs6tj|jd�}|��|j�|���}|�d|�dSrL)rrOr
rer%r'r(r�rrr�test_readline_empty_eof`sz#StreamTests.test_readline_empty_eofcCsZtj|jd�}|�|j�|j�|���|j�|�d��}|�d|�|�d|j	�dS)NrMr�sline2
lsine3
)
rrOr
rPrVr%r'r)r(rQrXrrr�test_readline_read_byte_countgsz)StreamTests.test_readline_read_byte_countcCshtj|jd�}|�d�|j�|���}|�d|�|�t��|�	t|jj|���|�d|j
�dS)NrMrorN)rrOr
rPr%r'r(rrrsrHrQrXrrr�test_readline_exceptionrs
�z#StreamTests.test_readline_exceptioncCsTtj|jd�}|�td��|j�|jdd��Wd�dS1s#wYdS)NrMzSeparator should berN��	separator)rrOr
rxrsr%�	readuntilrRrrr�test_readuntil_separator~s"�z$StreamTests.test_readuntil_separatorcCs�tj|jd�}|�d�|j�|jdd��}|�d|�|�d|j�|�d�|j�|�d��}|�d|�|�d|j�|�d�|j�|�d��}|�d|�|�d|j�dS)NrMslineAAA�AAAr�rNs
lineAAAxxxsxxx�rrOr
rPr%r�r(rQrXrrr�test_readuntil_multi_chunks�s


z'StreamTests.test_readuntil_multi_chunkscCsftj|jd�}|�d�|�d�|�d�|j�|�d��}|�d|�|�d|j�|�d�|�d�|�d	�|j�|�d��}|�d|�|�d|j�|�d�|j�|�d��}|�d|�|�d|j�|�d
�|j�|�d��}|�d
|�|�d|j�|�d�|�d�|�d�|�d�|j�|�d��}|�d|�|�d|j�dS)
NrMsQWEaasXYaa�asaaas
QWEaaXYaaarNsXYasaasXaaasXXXsXXXaaar�rXrrr�test_readuntil_multi_chunks_1�s8











z)StreamTests.test_readuntil_multi_chunks_1cCs�tj|jd�}d}|�|�|��|�tjd��}|j�|�d��Wd�n1s-wY|�	|j
j|�|�|j
j
�|�	d|j�dS)NrM�some dataAAzundefined expected bytesr�rN)rrOr
rPrerx�IncompleteReadErrorr%r�r(�	exception�partial�assertIsNone�expectedrQ)rrSr1r�rrr�test_readuntil_eof�s
��zStreamTests.test_readuntil_eofcCs�tj|jdd�}|�d�|�tjd��}|j�|�d��Wd�n1s(wY|�d|j	�|�d�|�tjd��}|j�|�d��Wd�n1sTwY|�d|j	�dS)	Nr|�r
rwr�z	not foundr��Azis foundssome dataAAA)
rrOr
rPrx�LimitOverrunErrorr%r�r(rQ)rrSr�rrr�test_readuntil_limit_found_sep�s"
��
��z*StreamTests.test_readuntil_limit_found_sepcCs�tj|jd�}|�|j�|j�|�d��}|�d|�|�|j|j�|�	t
d��|j�|�d��Wd�n1s>wY|�|j|j�dS)NrMrrNzless than zerori)rrOr
rPrVr%�readexactlyr(rQrxrsrXrrr�test_readexactly_zero_or_less�s�z)StreamTests.test_readexactly_zero_or_lesscs|tj�jd��dt�j�}�j���|��}��fdd�}�j�|��j�|�}��	�j�j|���	�j�j
�dS)NrMrpcs(���j����j����j�dSrr[rrRrrr\�sz(StreamTests.test_readexactly.<locals>.cb)rrOr
�lenrVr]r�r^r%r(rQ)r�nr`r\r1rrRr�test_readexactly�szStreamTests.test_readexactlycCrzr{)rrOr
rPr%r�r(rQrXrrr�test_readexactly_limit�r~z"StreamTests.test_readexactly_limitcs�tj�jd��dt�j�}�j���|��}��fdd�}�j�|���tj	��}�j�
|�Wd�n1s;wY��|jj
�j���|jj|���t|j�d���d�j�dS)NrMrpcs���j����dSr)rPrVrerrRrrr\sz,StreamTests.test_readexactly_eof.<locals>.cbz-18 bytes read on a total of 36 expected bytesrN)rrOr
r�rVr]r�r^rHr�r%r(r�r�r��strrQ)rr�r`r\r�rrRr�test_readexactly_eof�s��z StreamTests.test_readexactly_eofcCrmrn)
rrOr
rPr%r�r(rrrsrHrXrrr�test_readexactly_exception
ruz&StreamTests.test_readexactly_exceptioncCs@tj|jd�}|�|���t�}|�|�|�|��|�dSrU)rrOr
r�r�rsrr�assertIs�rrS�excrrr�test_exceptions

zStreamTests.test_exceptioncs`tj|jd���fdd�}|j�����}|j�|��}|j�t�||g��|�t|j	�dS)NrMc�s���t��dSr)rrrsrrfrr�set_err#s�z2StreamTests.test_exception_waiter.<locals>.set_err)
rrOr
r]r'r%�waitrHrs�result)rr��t1�t2rrfr�test_exception_waiter sz!StreamTests.test_exception_waitercCsjtj|jd�}|j�|���}t�|j�|��t�|j�|�t	d��t�|j�|�
|jd�dS)NrM�message)rrOr
r]r'rr�cancelrr�RuntimeErrorr��_waiter)rrS�trrr�test_exception_cancel-sz!StreamTests.test_exception_cancelcs�Gdd�d�}dd�}g�|j��fdd��||j�}|��}|j�|j�||���}|��|�|d�||j�}|��}|j�|j�||���}|��|�|d�|��g�dS)Nc@�<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)z/StreamTests.test_start_server.<locals>.MyServercSsd|_||_dSr)�serverr
)rr
rrr�__init__=s
z8StreamTests.test_start_server.<locals>.MyServer.__init__c��B�|��IdH}|�|�|��IdH|��|��IdHdSr�r'r&�drainr�wait_closed�r�
client_reader�
client_writerr1rrr�
handle_clientA��
z=StreamTests.test_start_server.<locals>.MyServer.handle_clientcSs,t�d�}|j�tj|j|d��|_|��S)N�z	127.0.0.1r)�sock)	�socket�
create_serverr
r%r�start_serverr�r��getsockname)rr�rrr�startHs
��z5StreamTests.test_start_server.<locals>.MyServer.startcS�|j�|�||��dSr�r
r]r��rr�r�rrr�handle_client_callbackO�
�zFStreamTests.test_start_server.<locals>.MyServer.handle_client_callbackcSsBt�d�}|��}|��|j�tj|j|d|dd��|_	|S)Nr�r�)�host�port)
r�r�r�rr
r%rr�r�r�)rr��addrrrr�start_callbackSs
��z>StreamTests.test_start_server.<locals>.MyServer.start_callbackcS�4|jdur|j��|j�|j���d|_dSdSr�r�rr
r%r�rrrr�stop\�



�z4StreamTests.test_start_server.<locals>.MyServer.stopN�	�__name__�
__module__�__qualname__r�r�r�r�r�r�rrrr�MyServer;s	r�c�sH�tj|�IdH\}}|�d�|��IdH}|��|��IdH|S�N�
hello world!
)rr5r&r'rr�)r�r.r/�msgbackrrr�clientb��
z-StreamTests.test_start_server.<locals>.clientcrrrrrrrrmr z/StreamTests.test_start_server.<locals>.<lambda>r�)r
r$r�r%r]r�r(r�)rr�r�r�r��msgrrr�test_start_server9s'


zStreamTests.test_start_servercsGdd�d�}dd�}g�|j��fdd��t���(}||j|�}|��|j�|j�||���}|��|�|d�Wd�n1sFwYt���(}||j|�}|�	�|j�|j�||���}|��|�|d�Wd�n1szwY|��g�dS)Nc@r�)z4StreamTests.test_start_unix_server.<locals>.MyServercSsd|_||_||_dSr)r�r
�path)rr
r�rrrr��s
z=StreamTests.test_start_unix_server.<locals>.MyServer.__init__c�r�rr�r�rrrr��r�zBStreamTests.test_start_unix_server.<locals>.MyServer.handle_clientcSs |j�tj|j|jd��|_dS�N)r�)r
r%r�start_unix_serverr�r�r�rrrrr��s
�
�z:StreamTests.test_start_unix_server.<locals>.MyServer.startcSr�rr�r�rrrr��r�zKStreamTests.test_start_unix_server.<locals>.MyServer.handle_client_callbackcSs$tj|j|jd�}|j�|�|_dSr�)rr�r�r�r
r%r�)rr�rrrr��s�zCStreamTests.test_start_unix_server.<locals>.MyServer.start_callbackcSr�rr�rrrrr��r�z9StreamTests.test_start_unix_server.<locals>.MyServer.stopNr�rrrrr��sr�c�sH�t�|�IdH\}}|�d�|��IdH}|��|��IdH|Sr�)rr=r&r'rr�)r�r.r/r�rrrr��r�z2StreamTests.test_start_unix_server.<locals>.clientcrrrrrrrr�r z4StreamTests.test_start_unix_server.<locals>.<lambda>r�)
r
r$rZunix_socket_pathr�r%r]r�r(r�)rr�r�r�r�r�rrr�test_start_unix_servers."

��
	��z"StreamTests.test_start_unix_server�win32zDon't have pipesc
	sd}t��\}}tjd|t|�g}t|dd�}tj|jdd�}tj	||jd��|j�
|j��fdd	�|��\}}t��}	|	�
|j�z#t�|	�tj|d
|hi�}
|j�
|
�}|j�
|���Wt�d�nt�d�wt�|�|j�
|�d��}|�|d�dS)
NzHimport os, sys
fd = int(sys.argv[1])
os.write(fd, b'data')
os.close(fd)
z-c�rbrr�r�rMcs�Srrr��protocolrrr�sz<StreamTests.test_read_all_from_pipe_reader.<locals>.<lambda>�pass_fdsri�data)�os�pipe�sys�
executabler��openrrOr
�StreamReaderProtocolr%Zconnect_read_pipeZSafeChildWatcherZattach_loopZset_child_watcherZcreate_subprocess_execr�rr)r()
r�codeZrfdZwfd�argsr�r.Z	transport�_ZwatcherZcreate�procr1rr�r�test_read_all_from_pipe_reader�s0�
��
z*StreamTests.test_read_all_from_pipe_readercCs:|�td��
t��Wd�dS1swYdS�Nzno current event loop)rxr�rrOrrrr�*test_streamreader_constructor_without_loop�s
"�z6StreamTests.test_streamreader_constructor_without_loopcCs*dd�}|j�|��}|�|j|j�dS)Nc�s
�t��Sr)rrOrrrr�test�s�zHStreamTests.test_streamreader_constructor_use_running_loop.<locals>.test)r
r%r��_loop)rrr.rrr�.test_streamreader_constructor_use_running_loop�sz:StreamTests.test_streamreader_constructor_use_running_loopcCs6|�tjd�t�|j�t��}|�|j|j�dSr)�
addCleanuprrr
rOr�r�rr.rrr�-test_streamreader_constructor_use_global_loop�sz9StreamTests.test_streamreader_constructor_use_global_loopcCsDt��}|�td��t�|�Wd�dS1swYdSr)r�Mockrxr�rr�rrrr�2test_streamreaderprotocol_constructor_without_loops"�z>StreamTests.test_streamreaderprotocol_constructor_without_loopcs6t����fdd�}|j�|��}|�|j|j�dS)Nc�s�t���Sr)rr�r�r.rrr
s�
zPStreamTests.test_streamreaderprotocol_constructor_use_running_loop.<locals>.test)rr
r
r%r�r)rrr�rrr�6test_streamreaderprotocol_constructor_use_running_loop	szBStreamTests.test_streamreaderprotocol_constructor_use_running_loopcCs@|�tjd�t�|j�t��}t�|�}|�|j|j�dSr)	rrrr
rr
r�r�r)rr.r�rrr�5test_streamreaderprotocol_constructor_use_global_loops

zAStreamTests.test_streamreaderprotocol_constructor_use_global_loopcs2d��fdd�����fdd�}�j�|��dS)Nrc�s�|��IdH�d7�dS)Nr�)Z
_drain_helperrf)�drainedrr�drainer s�z0StreamTests.test_multiple_drain.<locals>.drainerc�s`�t��}tj�|�����|�d�j�tj��fdd�td�D��IdH��	�d�dS)Ng�������?csg|]}����qSrr)�.0r�)rrSrr�
<listcomp>*szAStreamTests.test_multiple_drain.<locals>.main.<locals>.<listcomp>�
)
rZget_running_loopZstreamsZFlowControlMixinZ
pause_writingZ
call_laterZresume_writingZgather�ranger(rM�rrrrfr�main%s�$z-StreamTests.test_multiple_drain.<locals>.main)r
r%)rrrrr�test_multiple_drainszStreamTests.test_multiple_draincs�g�|j��fdd��t����fdd�}dd�}tj|d�}d|_|�����}|�	t
ttf��|j�
||��Wd�n1sFwY|��|�g��dS)	Ncrrrrrrrr8r z/StreamTests.test_drain_raises.<locals>.<lambda>csVt�d��}|��}��|�|��\}}|��Wd�dS1s$wYdS)N)�	localhostr)r�r�r��put�acceptr)r�r�Zcltr�)�qrrr�;s

"�z-StreamTests.test_drain_raises.<locals>.serverc�s4�t�||�IdH\}}	|�d�|��IdHq
)NTsfoo
)rr5r&r�)r�r�r.r/rrrr�Cs�
�z-StreamTests.test_drain_raises.<locals>.client)�targetT)r
r$�queue�Queue�	threading�Thread�daemonr��getrH�ConnectionResetError�ConnectionAbortedError�BrokenPipeErrorr%�joinr()rr�r��threadr�r)rrr�test_drain_raises/s ��zStreamTests.test_drain_raisescCs"tj|jd�}|�dt|��dS)NrM�<StreamReader>�rrOr
r(�reprrRrrr�
test___repr__ZszStreamTests.test___repr__cCs$tj|jdd�}|�dt|��dS)N�{r�z<StreamReader limit=123>r*rRrrr�test___repr__nondefault_limit^sz)StreamTests.test___repr__nondefault_limitcCs*tj|jd�}|��|�dt|��dS)NrMz<StreamReader eof>)rrOr
rer(r+rRrrr�test___repr__eofbszStreamTests.test___repr__eofcCs,tj|jd�}|�d�|�dt|��dS)NrMr�z<StreamReader 4 bytes>)rrOr
rPr(r+rRrrr�test___repr__datags
zStreamTests.test___repr__datacCs2tj|jd�}t�}|�|�|�dt|��dS)NrMz'<StreamReader exception=RuntimeError()>)rrOr
r�rrr(r+r�rrr�test___repr__exceptionls
�z"StreamTests.test___repr__exceptioncCsbtj|jd�}tj|jd�|_|�t|�d�|j�d�|j�|j�d|_|�	dt|��dS)NrMz,<StreamReader waiter=<Future pending[\S ]*>>r))
rrOr
�Futurer�ZassertRegexr+�
set_resultr%r(rRrrr�test___repr__waiterss�zStreamTests.test___repr__waitercCsBtj|jd�}t��|_t��|j_d|jj_|�dt	|��dS)NrMz<Transport>z$<StreamReader transport=<Transport>>)
rrOr
rr
Z
_transport�__repr__Zreturn_valuer(r+rRrrr�test___repr__transport~s


z"StreamTests.test___repr__transportc	Cs�t�dd�}ttjd�D]<}|j|d��,t�tj||d��}|�t	|�t	|��|�|j
|j
�|�|j|j�Wd�n1sDwYq
dS)Nsabcrr��Zpickle_protocolr�)rr�r�pickle�HIGHEST_PROTOCOL�subTest�loads�dumpsr(r�r�r��r�e�proto�e2rrr�#test_IncompleteReadError_pickleable�s���z/StreamTests.test_IncompleteReadError_pickleablec	Cs�t�dd�}ttjd�D]4}|j|d��$t�tj||d��}|�t	|�t	|��|�|j
|j
�Wd�n1s<wYq
dS)Nr�rr�r7r�)rr�rr8r9r:r;r<r(r��consumedr=rrr�!test_LimitOverrunError_pickleable�s���z-StreamTests.test_LimitOverrunError_pickleablecCs�t���V}|j�tj|j��\}}|�d�|��}|j�|�}|�	|d�|�
�}|j�|�}|�|�d��|�
|���|��|�|���|j�|���Wd�dS1s]wYdS�Nr!r"r#)rr4r
r%rr5r6r&r'r(r)r*r+r�Z
is_closingrr��rr8�rd�wrr0r1rrr�test_wait_closed_on_close�s 

�
"�z%StreamTests.test_wait_closed_on_closecCs�t���6}|j�tj|j��\}}|�d�|��}|j�|�}|�	|d�|�
�|j�|���Wd�dS1s=wYdS)Nr!r")rr4r
r%rr5r6r&r'r(rr�rErrr�*test_wait_closed_on_close_with_unread_data�s

�
"�z6StreamTests.test_wait_closed_on_close_with_unread_datac�l�fdd�}g��j��fdd��t���}�j�||��Wd�n1s)wY���g�dS)Nc�st�tj|j�IdH\}}|�d�|��IdH}��|d�|��IdH}��|�d��|�	�|�
�IdHdSrD)rr5r6r&r'r(r)r*r+rr��r8rFrGr1rrr�inner�s�
z0StreamTests.test_async_writer_api.<locals>.innercrrrrrrrr�r z3StreamTests.test_async_writer_api.<locals>.<lambda>�r
r$rr4r%r(�rrLr8r�rrr�test_async_writer_api�s
�z!StreamTests.test_async_writer_apicrJ)Nc�s��tj|j�IdH\}}|�d�|��IdH}��|d�|��IdH}��|�d��|�	���
t��|�d�|��IdHWd�dS1sNwYdS)Nr!r"r#r�)
rr5r6r&r'r(r)r*r+rrHr#r�rKrrrrL�s�

"�zFStreamTests.test_async_writer_api_exception_after_close.<locals>.innercrrrrrrrr�r zIStreamTests.test_async_writer_api_exception_after_close.<locals>.<lambda>rMrNrrOr�+test_async_writer_api_exception_after_close�s

�z7StreamTests.test_async_writer_api_exception_after_closecs�g�|j��fdd��t���9}|j�tj|j��\}}|��|�	�}|j�|�|�
|���|��}|j�|�}|�
|d�Wd�n1sLwY|�
�g�dS)Ncrrrrrrrr�r z?StreamTests.test_eof_feed_when_closing_writer.<locals>.<lambda>rN)r
r$rr4r%rr5r6rr�r*r�r)r(rErrr�!test_eof_feed_when_closing_writer�s

��z-StreamTests.test_eof_feed_when_closing_writer)Pr�r�r�rVrrr2r9rZskip_unless_bind_unix_socketr>r@�unittestZskipIfrBrDrFrIrJrKrTrWrYrardrhrlrtryr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��platformrrrr	rr
rrr(r,r.r/r0r1r4r6rArCrHrIrPrQrR�
__classcell__rrrrr
s�



	

/#


F
E
'	
	
+	r
�__main__)�__doc__rr�rr8r�r�rrSrZtest.supportrrB�ImportErrorrZtest.test_asynciorrr	ZTestCaser
r�rrrrr�<module>s<�^�