File: D:/Python311/Lib/test/test_asyncio/__pycache__/test_threads.cpython-311.pyc
�
��Vc� � � � d Z ddlZddlZddlmZ ddlmZ d� Z G d� dej � � Ze dk r ej
� � dS dS ) zTests for asyncio/threads.py� N)�
ContextVar)�mockc �. � t j d � � d S �N)�asyncio�set_event_loop_policy� � �2D:\Python311\Lib\test\test_asyncio\test_threads.py�tearDownModuler
s � ��!�$�'�'�'�'�'r
c �2 � e Zd Zd� Zd� Zd� Zd� Zd� Zd� ZdS )�
ToThreadTestsc � �z K � t j t ddg� � � d {V ��}| � |d� � d S )N�( � �* )r � to_thread�sum�assertEqual)�self�results r �test_to_threadzToThreadTests.test_to_thread sJ � � � ��(��r�1�g�6�6�6�6�6�6�6�6�������$�$�$�$�$r
c � � K � d� }| � t d� � 5 t j |� � � d {V �� d d d � � d S # 1 swxY w Y d S )Nc � � t d� � �)N�test)�RuntimeErrorr r
r �
raise_runtimez=ToThreadTests.test_to_thread_exception.<locals>.raise_runtime s � ��v�&�&�&r
r )�assertRaisesRegexr r r )r r s r �test_to_thread_exceptionz&ToThreadTests.test_to_thread_exception s� � � � � '� '� '� �
#�
#�L�&�
9�
9� 3� 3��#�M�2�2�2�2�2�2�2�2�2� 3� 3� 3� 3� 3� 3� 3� 3� 3� 3� 3� 3���� 3� 3� 3� 3� 3� 3s �A � A
�A
c � � K � t j � � }t j |� � � d {V �� |� � � d S r )r �Mockr r �assert_called_once�r �funcs r �test_to_thread_oncez!ToThreadTests.test_to_thread_once sL � � � ��y�{�{�����%�%�%�%�%�%�%�%�%����!�!�!�!�!r
c � � K � t j � � }g }t d� � D ]+}t j |� � }|� |� � �,t j |� � d {V �� | � |j d� � d S )N�
) r r! �ranger r �append�gatherr �
call_count)r r$ �futs�_�futs r �test_to_thread_concurrentz'ToThreadTests.test_to_thread_concurrent s� � � � ��y�{�{�����r��� � �A��#�D�)�)�C��K�K�������n�d�#�#�#�#�#�#�#�#������"�-�-�-�-�-r
c � � K � t j � � }t j |dd�� � � d {V �� |� dd�� � d S )Nr T)� something)r r! r r �assert_called_once_withr# s r �test_to_thread_args_kwargsz(ToThreadTests.test_to_thread_args_kwargs+ sZ � � � ��y�{�{�����f��=�=�=�=�=�=�=�=�=�=��$�$�V�t�$�<�<�<�<�<r
c � � �K � t d� � ��fd�}�� d� � t j |� � � d {V ��}| � |d� � d S )N�test_ctxc �, �� � � � � S r )�get)r5 s �r �get_ctxz9ToThreadTests.test_to_thread_contextvars.<locals>.get_ctx6 s �� ��<�<�>�>�!r
�parrot)r �setr r r )r r8 r r5 s @r �test_to_thread_contextvarsz(ToThreadTests.test_to_thread_contextvars3 s �� � � ��j�)�)�� "� "� "� "� "� ���X�����(��1�1�1�1�1�1�1�1�������*�*�*�*�*r
N) �__name__�
__module__�__qualname__r r r% r/ r3 r; r r
r r r sn � � � � � �%� %� %�3� 3� 3�"� "� "� .� .� .�=� =� =� +� +� +� +� +r
r �__main__)�__doc__r �unittest�contextvarsr r r �IsolatedAsyncioTestCaser r<