Your IP : 216.73.216.85


Current Path : /opt/alt/python310/lib64/python3.10/test/test_asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/test_asyncio/__pycache__/test_threads.cpython-310.pyc

o

0�iZ�@s^dZddlZddlZddlmZddlmZdd�ZGdd�dej�Ze	d	kr-e�
�dSdS)
zTests for asyncio/threads.py�N)�
ContextVar)�mockcCst�d�dS�N)�asyncioZset_event_loop_policy�rr�E/opt/alt/python310/lib64/python3.10/test/test_asyncio/test_threads.py�tearDownModule
src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
ToThreadTestsc�s(�t�tddg�IdH}|�|d�dS)N�(��*)r�	to_thread�sum�assertEqual)�self�resultrrr�test_to_threads�zToThreadTests.test_to_threadc�sL�dd�}|�td��t�|�IdHWd�dS1swYdS)NcSstd��)N�test)�RuntimeErrorrrrr�
raise_runtime�z=ToThreadTests.test_to_thread_exception.<locals>.raise_runtimer)ZassertRaisesRegexrrr
)rrrrr�test_to_thread_exceptions
�"�z&ToThreadTests.test_to_thread_exceptionc�s&�t��}t�|�IdH|��dSr)r�Mockrr
Zassert_called_once�r�funcrrr�test_to_thread_onces�z!ToThreadTests.test_to_thread_oncec�sR�t��}g}td�D]}t�|�}|�|�qtj|�IdH|�|jd�dS)N�
)	rr�rangerr
�appendZgatherrZ
call_count)rrZfuts�_Zfutrrr�test_to_thread_concurrent s�
z'ToThreadTests.test_to_thread_concurrentc�s2�t��}tj|ddd�IdH|jddd�dS)NrT)Z	something)rrrr
Zassert_called_once_withrrrr�test_to_thread_args_kwargs+s�z(ToThreadTests.test_to_thread_args_kwargsc�s@�td���fdd�}��d�t�|�IdH}|�|d�dS)N�test_ctxcs���Sr)�getr�r"rr�get_ctx6rz9ToThreadTests.test_to_thread_contextvars.<locals>.get_ctxZparrot)r�setrr
r)rr%rrr$r�test_to_thread_contextvars3s�
z(ToThreadTests.test_to_thread_contextvarsN)	�__name__�
__module__�__qualname__rrrr r!r'rrrrr	sr	�__main__)�__doc__rZunittestZcontextvarsrrrZIsolatedAsyncioTestCaser	r(�mainrrrr�<module>s1�