Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/test_asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_asyncio/__pycache__/test_threads.cpython-39.opt-1.pyc

a

XC?h�	�@sfdZddlZddlZddlmZddlmZddlmZdd�Z	Gdd	�d	ej
�Zed
krbe�
�dS)zTests for asyncio/threads.py�N)�
ContextVar)�mock)�utilscCst�d�dS�N)�asyncioZset_event_loop_policy�rr�C/opt/alt/python39/lib64/python3.9/test/test_asyncio/test_threads.py�tearDownModulesr	csXeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�
ToThreadTestscs$t���t��|_t�|j�dSr)�super�setUprZnew_event_loop�loop�set_event_loop��self��	__class__rrrs

zToThreadTests.setUpcs:|j�|j���|j��t�d�d|_t���dSr)r
�run_until_completeZshutdown_default_executor�closerrr�tearDownrrrrrs�

zToThreadTests.tearDowncCs&dd�}|j�|��}|�|d�dS)Nc�st�tddg�IdHS)N�(�)r�	to_thread�sumrrrr�mainsz*ToThreadTests.test_to_thread.<locals>.main�*)r
r�assertEqual�rr�resultrrr�test_to_threadszToThreadTests.test_to_threadcsRdd���fdd�}|�td��|j�|��Wd�n1sD0YdS)NcSstd��dS)N�test)�RuntimeErrorrrrr�
raise_runtime%sz=ToThreadTests.test_to_thread_exception.<locals>.raise_runtimec�st���IdHdSr�rrr�r"rrr(sz4ToThreadTests.test_to_thread_exception.<locals>.mainr )ZassertRaisesRegexr!r
r�rrrr$r�test_to_thread_exception$sz&ToThreadTests.test_to_thread_exceptioncs.t����fdd�}|j�|�����dS)Nc�st���IdHdSrr#r��funcrrr1sz/ToThreadTests.test_to_thread_once.<locals>.main)r�Mockr
rZassert_called_oncer%rr'r�test_to_thread_once.sz!ToThreadTests.test_to_thread_oncecs4t����fdd�}|j�|��|��jd�dS)Nc�s:g}td�D]}t���}|�|�qtj|�IdHdS)N�
)�rangerr�appendZgather)Zfuts�_Zfutr'rrr:s

z5ToThreadTests.test_to_thread_concurrent.<locals>.mainr+)rr)r
rrZ
call_countr%rr'r�test_to_thread_concurrent7sz'ToThreadTests.test_to_thread_concurrentcs4t����fdd�}|j�|���jddd�dS)Nc�stj�ddd�IdHdS)Nr T�Z	somethingr#rr'rrrHsz6ToThreadTests.test_to_thread_args_kwargs.<locals>.mainr Tr0)rr)r
rZassert_called_once_withr%rr'r�test_to_thread_args_kwargsDsz(ToThreadTests.test_to_thread_args_kwargscs@td���fdd����fdd�}|j�|��}|�|d�dS)N�test_ctxcs���Sr)�getr)r2rr�get_ctxQsz9ToThreadTests.test_to_thread_contextvars.<locals>.get_ctxc�s��d�t���IdHS)N�parrot)�setrrr�r4r2rrrTs
z6ToThreadTests.test_to_thread_contextvars.<locals>.mainr5)rr
rrrrr7r�test_to_thread_contextvarsNs
z(ToThreadTests.test_to_thread_contextvars)�__name__�
__module__�__qualname__rrrr&r*r/r1r8�
__classcell__rrrrr
s
	

r
�__main__)�__doc__rZunittestZcontextvarsrrZtest.test_asynciorZ
test_utilsr	ZTestCaser
r9rrrrr�<module>sM