Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_asynchat.cpython-38.pyc
U

>��g#%�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z	ejZdZdZ
Gdd�dej�ZGdd�dej�Zd	d
�ZGdd�de	j�ZGd
d�de�ZGdd�de	j�ZGdd�de	j�ZGdd�de	j�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�1/opt/cppython/lib/python3.8/test/test_asynchat.pyrs
zecho_server.__init__cCs�|j��|j��|j��\}}d|_t|jkrP|�d�}|sBqP|j||_q(|j�td�|_|j	rp|j	�
�z<|jr�|�|jd|j��}t
�d�|j|d�|_qrWnYnX|��|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"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)NrcSsdSrr�rrrr�handle_connectLsz,echo_client.__init__.<locals>.handle_connect�darwincSsdSrrr*rrr�handle_exptRsz)echo_client.__init__.<locals>.handle_expt)�asynchat�
async_chatr�contentsZ
create_socketr
rr�connect�HOST�set_terminatorr�sys�platform)r�
terminatorZserver_portr+r-rrrrDs

zecho_client.__init__cCs|j|7_dSr)r)rr#rrr�collect_incoming_dataUsz!echo_client.collect_incoming_datacCs|j�|j�d|_dS)Nr)r0�appendrr*rrr�found_terminatorXszecho_client.found_terminatorN)r&r'r(rr7r9rrrrr)Bsr)cCs:t��}t|�}|��|��|��t�d�||fS)N�{�G�z�?)r�Eventr�startr�clearrr)r	�srrr�start_echo_server\s
r?c@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�_threadsr*rrr�setUpiszTestAsynchat.setUpcCstj|j�dSr)rZthreading_cleanuprAr*rrr�tearDownlszTestAsynchat.tearDowncCs�t��}t|�}||_|��|��|��t�d�t	||j
�}|�d�|�d|�|�d|�|�t�t
j|jddd�tj|td�|�|jddg�dS)	Nr:shello sworld�I'm not dead yet!�,�Zuse_poll�count�timeout�rH�hello world)rr;rrr<rr=rrr)r�pushr�asyncore�loop�usepollr�join_thread�TIMEOUT�assertEqualr0)rZtermZserver_chunkr	r>�crrr�line_terminator_checkos


z"TestAsynchat.line_terminator_checkcCsdD]}|�d|�qdS)N�r���
�rS�r�lrrr�test_line_terminator1�sz"TestAsynchat.test_line_terminator1cCsdD]}|�d|�qdS)NrTs
rXrYrrr�test_line_terminator2�sz"TestAsynchat.test_line_terminator2cCsdD]}|�d|�qdS)NrTsqqqrXrYrrr�test_line_terminator3�sz"TestAsynchat.test_line_terminator3cCsjt�\}}t||j�}d}|�|�|�t�tj|jddd�tj	|t
d�|�|j|d|�g�dS�Nshello world, I'm not dead yet!
rEr:rFrI�
r?r)rrKrrLrMrNrrOrPrQr0)rZtermlenr>r	rRr#rrr�numeric_terminator_check�s


z%TestAsynchat.numeric_terminator_checkcCs|�d�dS)Nr�r`r*rrr�test_numeric_terminator1�sz%TestAsynchat.test_numeric_terminator1cCs|�d�dS)N�rar*rrr�test_numeric_terminator2�sz%TestAsynchat.test_numeric_terminator2cCsnt�\}}td|j�}d}|�|�|�t�tj|jddd�tj	|t
d�|�|jg�|�|j
|�dSr^)r?r)rrKrrLrMrNrrOrPrQr0r�rr>r	rRr#rrr�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)NrW�hello world
I'm not dead yet!
�)Zbuffer_sizerEr:rFrIrJrD)r?r)rr.Zsimple_producerr�push_with_producerrLrMrNrrOrPrQr0)rr>r	rRr#�prrr�test_simple_producer�s

z!TestAsynchat.test_simple_producercCs^t�\}}td|j�}d}|�|t�tj|jddd�tj	|t
d�|�|jddg�dS)	NrWrgrEr:rFrIrJrD)
r?r)rrirrLrMrNrrOrPrQr0rerrr�test_string_producer�s
z!TestAsynchat.test_string_producercCsbt�\}}td|j�}|�d�|�t�tj|jddd�tj	|t
d�|�|jddd	g�dS)
NrWshello world

I'm not dead yet!
rEr:rFrIrJrrDr_�rr>r	rRrrr�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)NrWrgrEr:rFrIr)r?rr;rr)rrKrZclose_when_donerLrMrNrrrOrPrQr0Z
assertGreater�lenrrmrrr�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)
NrWsbytes
�
�unicoderEr:rFrIsbytes)r?r)rrK�	bytearray�
memoryview�assertRaises�	TypeErrorrrLrMrNrrOrPrQr0rerrr�	test_push�s


zTestAsynchat.test_pushN)r&r'r(rNrBrCrSr[r\r]r`rbrdrfrkrlrnrprwrrrrr@fs 

r@c@seZdZdZdS)�TestAsynchat_WithPollTN)r&r'r(rNrrrrrx�srxc@seZdZdd�ZdS)�TestAsynchatMockedc	Csjtj��}ttj�|j_t�	�}|�
|�|�|j�tjj
�|d��}|��W5QRX|�|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�rrrrrysryc@seZdZdd�ZdS)�TestHelperFunctionscCs,|�t�dd�d�|�t�dd�d�dS)Nzqwerty
z
rZ
qwertydkjfr)rQr.Zfind_prefix_at_endr*rrr�test_find_prefix_at_endsz+TestHelperFunctions.test_find_prefix_at_endN)r&r'r(r�rrrrr�sr�c@seZdZdd�ZdS)�TestNotConnectedcCst��}|�t|jd�dS)N���)r.r/ru�
ValueErrorr3)rr"rrr�!test_disallow_negative_terminatorsz2TestNotConnected.test_disallow_negative_terminatorN)r&r'r(r�rrrrr�sr��__main__)�testrr.rLr|r
r4rrrzZ
unittest.mockr2rrPrrr/r)r?ZTestCaser@rxryr�r�r&�mainrrrr�<module>s..


F1le Man4ger