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/__pycache__/test_asynchat.cpython-310.pyc
o

�i�%�@sNddlmZddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZ
ddlZe�
��e�de�ddlZddlZWd�n1sOwYejZdZGdd�dej�ZGd	d
�d
ej�Zdd�ZGd
d�de
j�ZGdd�de�ZGdd�de
j�ZGdd�de
j�ZGdd�de
j�Zedkr�e
� �dSdS)�)�support)�
socket_helper)�threading_helperN�ignoresQUIT
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.10/test/test_asynchat.pyrs

zecho_server.__init__cCs�|j��|j��|j��\}}d|_t|jvr,|�d�}|s!n|j||_t|jvs|j�td�|_|j	r<|j	�
�z |jr[|�|jd|j��}t
�d�|j|d�|_|js@WnY|��|j��dS)N�rg����MbP?)r�listenr�set�accept�buffer�SERVER_QUIT�recv�replacer�wait�send�
chunk_size�time�sleep�close)r�conn�client�data�nrrr�run's0




�

��zecho_server.runN)�__name__�
__module__�__qualname__r rr(rrrrrs	rc@s>eZdZdd�Zdd�Zejdkrdd�Zdd	�Zd
d�Z	dS)
�echo_clientcCsDtj�|�g|_|�tjtj�|�t	|f�|�
|�d|_dS�Nr)�asynchat�
async_chatr�contentsZ
create_socketr
rr�connect�HOST�set_terminatorr)r�
terminatorZserver_portrrrrIs

zecho_client.__init__cC�dSrr�rrrr�handle_connectQ�zecho_client.handle_connect�darwincCr5rrr6rrr�handle_exptWr8zecho_client.handle_exptcCs|j|7_dSr)r)rr&rrr�collect_incoming_dataZsz!echo_client.collect_incoming_datacCs|j�|j�d|_dSr-)r0�appendrr6rrr�found_terminator]s
zecho_client.found_terminatorN)
r)r*r+rr7�sys�platformr:r;r=rrrrr,Gs
r,cCs:t��}t|�}|��|��|��t�d�||fS)N�{�G�z�?)r	�Eventr�startr�clearr!r")r�srrr�start_echo_serveras
rEc@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��|_dSr)rZthreading_setup�_threadsr6rrr�setUpn�zTestAsynchat.setUpcCstj|j�dSr)rZthreading_cleanuprGr6rrr�tearDownqszTestAsynchat.tearDowncCs�t��}t|�}||_|��|��|��t�d�t	||j
�}|�d�|�d|�|�d|�|�t�t
j|jddd�t�|�|�|jddg�dS)Nr@shello sworld�I'm not dead yet!�,�Zuse_poll�count�timeout�hello world)r	rArr rBrrCr!r"r,r�pushr�asyncore�loop�usepollr�join_thread�assertEqualr0)rZtermZserver_chunkrrD�crrr�line_terminator_checkts



z"TestAsynchat.line_terminator_checkcC�dD]}|�d|�qdS)N�r���
�rX�r�lrrr�test_line_terminator1���z"TestAsynchat.test_line_terminator1cCrY)NrZs
r^r_rrr�test_line_terminator2�rbz"TestAsynchat.test_line_terminator2cCrY)NrZsqqqr^r_rrr�test_line_terminator3�rbz"TestAsynchat.test_line_terminator3cCsft�\}}t||j�}d}|�|�|�t�tj|jddd�t�	|�|�
|j|d|�g�dS�Nshello world, I'm not dead yet!
rLr@rM�rEr,rrQrrRrSrTrrUrVr0)rZtermlenrDrrWr&rrr�numeric_terminator_check�s



z%TestAsynchat.numeric_terminator_checkcC�|�d�dS)Nr�rgr6rrr�test_numeric_terminator1�sz%TestAsynchat.test_numeric_terminator1cCrh)N�rir6rrr�test_numeric_terminator2�rIz%TestAsynchat.test_numeric_terminator2cCsjt�\}}td|j�}d}|�|�|�t�tj|jddd�t�	|�|�
|jg�|�
|j|�dSre)
rEr,rrQrrRrSrTrrUrVr0r�rrDrrWr&rrr�test_none_terminator�s



z!TestAsynchat.test_none_terminatorcCsht�\}}td|j�}d}tj|tdd�}|�|�tj|j	ddd�t
�|�|�|j
dd	g�dS)
Nr]�hello world
I'm not dead yet!
�)Zbuffer_sizerLr@rMrPrK)rEr,rr.Zsimple_producerr�push_with_producerrRrSrTrrUrVr0)rrDrrWr&�prrr�test_simple_producer�s


z!TestAsynchat.test_simple_producercCsZt�\}}td|j�}d}|�|t�tj|jddd�t�	|�|�
|jddg�dS)Nr]rorLr@rMrPrK)rEr,rrqrrRrSrTrrUrVr0rmrrr�test_string_producer�s

z!TestAsynchat.test_string_producercCs\t�\}}td|j�}|�d�|�t�tj|jddd�t�	|�|�
|jgd��dS)Nr]shello world

I'm not dead yet!
rLr@rM)rPrrKrf�rrDrrWrrr�test_empty_line�s



�zTestAsynchat.test_empty_linecCs�t�\}}t��|_td|j�}|�d�|�t�|��t	j
|jddd�|j��t
�|�|�|jg�|�t|j�d�dS)Nr]rorLr@rMr)rEr	rArr,rrQrZclose_when_donerRrSrTrrrUrVr0Z
assertGreater�lenrrurrr�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�
|�|�|jgd��dS)	Nr]sbytes
�
�unicoderLr@rM)�bytesr{r{)rEr,rrQ�	bytearray�
memoryview�assertRaises�	TypeErrorrrRrSrTrrUrVr0rmrrr�	test_push�s



zTestAsynchat.test_pushN)r)r*r+rTrHrJrXrarcrdrgrjrlrnrsrtrvrxr�rrrrrFks"

rFc@seZdZdZdS)�TestAsynchat_WithPollTN)r)r*r+rTrrrrr�sr�c@�eZdZdd�ZdS)�TestAsynchatMockedcCs~tj��}ttj�|j_t�	�}|�
|�|�|j�tjj
�|d��}|��Wd�n1s2wY|�|j�dS)NZhandle_error)�unittestZmockZMock�BlockingIOError�errno�EAGAINrZside_effectr.r/Z
set_socketZ
addCleanupZdel_channelZpatch�objectZhandle_readZassertFalseZcalled)rr�
dispatcher�errorrrr�test_blockingioerrors


�z'TestAsynchatMocked.test_blockingioerrorN)r)r*r+r�rrrrr��r�c@r�)�TestHelperFunctionscCs,|�t�dd�d�|�t�dd�d�dS)Nzqwerty
z
rZ
qwertydkjfr)rVr.Zfind_prefix_at_endr6rrr�test_find_prefix_at_endsz+TestHelperFunctions.test_find_prefix_at_endN)r)r*r+r�rrrrr�r�r�c@r�)�TestNotConnectedcCst��}|�t|jd�dS)N���)r.r/r~�
ValueErrorr3)rr%rrr�!test_disallow_negative_terminatorsz2TestNotConnected.test_disallow_negative_terminatorN)r)r*r+r�rrrrr�r�r��__main__)!�testrZtest.supportrrr�r
r>r	r!r�Z
unittest.mock�warnings�catch_warnings�simplefilter�DeprecationWarningr.rRr2rr
rr/r,rEZTestCaserFr�r�r�r�r)�mainrrrr�<module>s<

�.
�