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: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_asynchat.cpython-37.pyc
B

��g<%�@sddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZej
Z
dZdZGdd�de	j�ZGdd�dej�Zd	d
�ZGdd�dej�ZGd
d�de�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�e��dS)�)�supportNsQUIT
g@c@s eZdZdZdd�Zdd�ZdS)�echo_server�cCs<tj�|�||_t�tjtj�|_t�	|j�|_
d|_dS)N)�	threading�Thread�__init__�event�socket�AF_INET�SOCK_STREAM�sockrZ	bind_port�port�start_resend_event)�selfr�r�./usr/local/lib/python3.7/test/test_asynchat.pyrs
zecho_server.__init__cCs�|j��|j��|j��\}}d|_x*t|jkrR|�d�}|sDP|j||_q*W|j�td�|_|j	rt|j	�
�y@x:|jr�|�|jd|j��}t
�d�|j|d�|_qxWWnYnX|��|j��dS)N�rg����MbP?)rZlistenr�setZaccept�buffer�SERVER_QUIT�recv�replacer�wait�send�
chunk_size�time�sleep�close)rZconn�client�data�nrrr�run#s*




zecho_server.runN)�__name__�
__module__�__qualname__rrr!rrrrrs	rc@s$eZdZdd�Zdd�Zdd�ZdS)�echo_clientcCs^tj�|�g|_|�tjtj�|�t	|f�|�
|�d|_dd�}tj
dkrZdd�}dS)NrcSsdS)Nr)rrrr�handle_connectMsz,echo_client.__init__.<locals>.handle_connect�darwincSsdS)Nr)rrrr�handle_exptSsz)echo_client.__init__.<locals>.handle_expt)�asynchat�
async_chatr�contentsZ
create_socketr	r
rZconnect�HOST�set_terminatorr�sys�platform)r�
terminatorZserver_portr&r(rrrrEs

zecho_client.__init__cCs|j|7_dS)N)r)rrrrr�collect_incoming_dataVsz!echo_client.collect_incoming_datacCs|j�|j�d|_dS)Nr)r+�appendr)rrrr�found_terminatorYszecho_client.found_terminatorN)r"r#r$rr1r3rrrrr%Csr%cCs:t��}t|�}|��|��|��t�d�||fS)Ng{�G�z�?)r�Eventr�startr�clearrr)r�srrr�start_echo_server]s
r8c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!�TestAsynchatFcCst��|_dS)N)rZthreading_setup�_threads)rrrr�setUpjszTestAsynchat.setUpcCstj|j�dS)N)rZthreading_cleanupr:)rrrr�tearDownmszTestAsynchat.tearDowncCs�t��}t|�}||_|��|��|��t�d�t	||j
�}|�d�|�d|�|�d|�|�t�t
j|jddd�tj|td�|�|jddg�dS)	Ng{�G�z�?shello sworldsI'm not dead yet!i,)�use_poll�count�timeout)r?shello world)rr4rrr5rr6rrr%r
�pushr�asyncore�loop�usepollr�join_thread�TIMEOUT�assertEqualr+)rZtermZserver_chunkrr7�crrr�line_terminator_checkps


z"TestAsynchat.line_terminator_checkcCsxdD]}|�d|�qWdS)N)r���
)rH)r�lrrr�test_line_terminator1�s
z"TestAsynchat.test_line_terminator1cCsxdD]}|�d|�qWdS)N)rrIrJs
)rH)rrLrrr�test_line_terminator2�s
z"TestAsynchat.test_line_terminator2cCsxdD]}|�d|�qWdS)N)rrIrJsqqq)rH)rrLrrr�test_line_terminator3�s
z"TestAsynchat.test_line_terminator3cCsjt�\}}t||j�}d}|�|�|�t�tj|jddd�tj	|t
d�|�|j|d|�g�dS)Nshello world, I'm not dead yet!
i,g{�G�z�?)r=r>r?)r?)
r8r%r
r@rrArBrCrrDrErFr+)rZtermlenr7rrGrrrr�numeric_terminator_check�s


z%TestAsynchat.numeric_terminator_checkcCs|�d�dS)Nr)rP)rrrr�test_numeric_terminator1�sz%TestAsynchat.test_numeric_terminator1cCs|�d�dS)N�)rP)rrrr�test_numeric_terminator2�sz%TestAsynchat.test_numeric_terminator2cCsnt�\}}td|j�}d}|�|�|�t�tj|jddd�tj	|t
d�|�|jg�|�|j
|�dS)Nshello world, I'm not dead yet!
i,g{�G�z�?)r=r>r?)r?)r8r%r
r@rrArBrCrrDrErFr+r)rr7rrGrrrr�test_none_terminator�s


z!TestAsynchat.test_none_terminatorcCslt�\}}td|j�}d}tj|tdd�}|�|�tj|j	ddd�t
j|td�|�
|jd	d
g�dS)NrKshello world
I'm not dead yet!
�)�buffer_sizei,g{�G�z�?)r=r>r?)r?shello worldsI'm not dead yet!)r8r%r
r)Zsimple_producerr�push_with_producerrArBrCrrDrErFr+)rr7rrGr�prrr�test_simple_producer�s

z!TestAsynchat.test_simple_producercCs^t�\}}td|j�}d}|�|t�tj|jddd�tj	|t
d�|�|jddg�dS)	NrKshello world
I'm not dead yet!
i,g{�G�z�?)r=r>r?)r?shello worldsI'm not dead yet!)
r8r%r
rWrrArBrCrrDrErFr+)rr7rrGrrrr�test_string_producer�s
z!TestAsynchat.test_string_producercCsbt�\}}td|j�}|�d�|�t�tj|jddd�tj	|t
d�|�|jddd	g�dS)
NrKshello world

I'm not dead yet!
i,g{�G�z�?)r=r>r?)r?shello worldrsI'm not dead yet!)
r8r%r
r@rrArBrCrrDrErFr+)rr7rrGrrr�test_empty_line�s


zTestAsynchat.test_empty_linecCs�t�\}}t��|_td|j�}|�d�|�t�|��t	j
|jddd�|j��t
j|td�|�|jg�|�t|j�d�dS)NrKshello world
I'm not dead yet!
i,g{�G�z�?)r=r>r?)r?r)r8rr4rr%r
r@rZclose_when_donerArBrCrrrDrErFr+Z
assertGreater�lenr)rr7rrGrrr�test_close_when_done�s




z!TestAsynchat.test_close_when_donecCs�t�\}}td|j�}d}|�|�|�t|��|�t|��|�t|jd�|�t|jd�|�t�t	j
|jddd�tj
|td�|�|jd	d	d	g�dS)
NrKsbytes
�
Zunicodei,g{�G�z�?)r=r>r?)r?sbytes)r8r%r
r@�	bytearray�
memoryview�assertRaises�	TypeErrorrrArBrCrrDrErFr+)rr7rrGrrrr�	test_push�s


zTestAsynchat.test_pushN)r"r#r$rCr;r<rHrMrNrOrPrQrSrTrYrZr[r]rcrrrrr9gs 

r9c@seZdZdZdS)�TestAsynchat_WithPollTN)r"r#r$rCrrrrrd�srdc@seZdZdd�ZdS)�TestAsynchatMockedc	Csjtj��}ttj�|j_t�	�}|�
|�|�|j�tjj
�|d��}|��WdQRX|�|j�dS)NZhandle_error)�unittestZmockZMock�BlockingIOError�errnoZEAGAINrZside_effectr)r*Z
set_socketZ
addCleanupZdel_channelZpatch�objectZhandle_readZassertFalseZcalled)rrZ
dispatcher�errorrrr�test_blockingioerrors

z'TestAsynchatMocked.test_blockingioerrorN)r"r#r$rkrrrrresrec@seZdZdd�ZdS)�TestHelperFunctionscCs,|�t�dd�d�|�t�dd�d�dS)Nzqwerty
z
rZ
qwertydkjfr)rFr)Zfind_prefix_at_end)rrrr�test_find_prefix_at_endsz+TestHelperFunctions.test_find_prefix_at_endN)r"r#r$rmrrrrrlsrlc@seZdZdd�ZdS)�TestNotConnectedcCst��}|�t|jd�dS)N���)r)r*ra�
ValueErrorr-)rrrrr�!test_disallow_negative_terminatorsz2TestNotConnected.test_disallow_negative_terminatorN)r"r#r$rqrrrrrnsrn�__main__)Ztestrr)rArhr	r.�_threadZthreadrrrfZ
unittest.mockr,rrErrr*r%r8ZTestCaser9rdrerlrnr"�mainrrrr�<module>s0.