Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_contextlib.cpython-312.opt-1.pyc

�

'ΜgO�����dZddlZddlZddlZddlZddlZddlZddlZddl�ddl	m
Z
ddlmZddl
mZddlZGd�dej �ZGd	�d
ej �ZGd�dej �ZGd
�dej �ZGd�dej �ZGd�dej �ZGd�de�ZGd�dej �ZGd�d�ZGd�deej �ZGd�d�ZGd�deej �ZGd�d eej �ZGd!�d"eej �ZGd#�d$ej �Z e!d%k(rejD�yy)&z9Unit tests for contextlib.py, and other context managers.�N)�*)�support)�	os_helper)�ExceptionIsLikeMixinc��eZdZd�Zd�Zd�Zy)�TestAbstractContextManagerc�p�Gd�dt�}|�}|j|j�|�y)Nc���eZdZ�fd�Z�xZS)�;TestAbstractContextManager.test_enter.<locals>.DefaultEnterc���t�|�|�y�N��super�__exit__��self�args�	__class__s  ��1/usr/local/lib/python3.12/test/test_contextlib.pyrzDTestAbstractContextManager.test_enter.<locals>.DefaultEnter.__exit__������ �$�'���__name__�
__module__�__qualname__r�
__classcell__�rs@r�DefaultEnterr�
���
(�
(rr)�AbstractContextManager�assertIs�	__enter__)rr�managers   r�
test_enterz%TestAbstractContextManager.test_enters/��	(�1�	(��.���
�
�g�'�'�)�7�3rc��Gd�dt�}|jt�5|�ddd�y#1swYyxYw)Nc��eZdZy)�ETestAbstractContextManager.test_exit_is_abstract.<locals>.MissingExitN�rrr�rr�MissingExitr'���rr*)r �assertRaises�	TypeError)rr*s  r�test_exit_is_abstractz0TestAbstractContextManager.test_exit_is_abstracts0��	�0�	��
�
�y�
)��M�*�
)�
)�s�6�?c�Z�Gd�d�}|jt|t��Gd�dt�}|jt|t��Gd�d|�}|jt|t��Gd�d|�}|jt|t��y)	Nc��eZdZd�Zd�Zy)�RTestAbstractContextManager.test_structural_subclassing.<locals>.ManagerFromScratchc��|Sr
r)�rs rr"z\TestAbstractContextManager.test_structural_subclassing.<locals>.ManagerFromScratch.__enter__$����rc��yr
r))r�exc_type�	exc_value�	tracebacks    rrz[TestAbstractContextManager.test_structural_subclassing.<locals>.ManagerFromScratch.__exit__&s��rN�rrrr"rr)rr�ManagerFromScratchr1#s��
�
rr:c���eZdZ�fd�Z�xZS)�LTestAbstractContextManager.test_structural_subclassing.<locals>.DefaultEnterc���t�|�|�yr
rrs  �rrzUTestAbstractContextManager.test_structural_subclassing.<locals>.DefaultEnter.__exit__,rrrrs@rrr<+rrrc��eZdZdZy)�GTestAbstractContextManager.test_structural_subclassing.<locals>.NoEnterN�rrrr"r)rr�NoEnterr?1s���IrrAc��eZdZdZy)�FTestAbstractContextManager.test_structural_subclassing.<locals>.NoExitN�rrrrr)rr�NoExitrC6s���HrrE)�
assertTrue�
issubclassr �assertFalse)rr:rrArEs     r�test_structural_subclassingz6TestAbstractContextManager.test_structural_subclassing"s���	�	�	
���
�#5�7M�N�O�	(�1�	(�	
���
�<�1G�H�I�	�(�	�	
����G�-C�D�E�	�'�	�	
����F�,B�C�DrN)rrrr$r.rIr)rrrrs��4��Errc���eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zej&d��Zej&d��Zd�Zd�Zd�Zd�Zy)�ContextManagerTestCasec����g�t�fd��}|�5}|j�dg�|j|d��j|�ddd�|j�gd��y#1swY�xYw)Nc3�Z�K��jd�d���jd�y�w�N��*����append��states�r�woohooz@ContextManagerTestCase.test_contextmanager_plain.<locals>.woohoo@s#������L�L��O��H��L�L�����(+rOrP�rOrPrQ)�contextmanager�assertEqualrS�rrV�xrUs   @r�test_contextmanager_plainz0ContextManagerTestCase.test_contextmanager_plain>so�����	�	�
�	��X�����U�Q�C�(����Q��#��L�L��O��	
�����-�	�X�s�7A-�-A6c�N��g�t�fd��}|jt�5|�5}|j�dg�|j|d��j	|�t��#1swYnxYw	ddd�n#1swYnxYw|j�gd��y)Nc3��K��jd�	d���jd�y#�jd�wxYw�wrNrRrTs�rrVzBContextManagerTestCase.test_contextmanager_finally.<locals>.woohooMs4������L�L��O�
"������S�!�����S�!�s�A�,�A�?�ArOrPrX)rYr,�ZeroDivisionErrorrZrSr[s   @r�test_contextmanager_finallyz2ContextManagerTestCase.test_contextmanager_finallyKs������	�	"�
�	"��
�
�0�
1���Q�� � ����,�� � ��B�'����Q��'�)�)�	����2�
1�
1��	
�����-s�B�AA0�0A9	�5B�Bc�@�td��}	|�5ddzddd�|jt
�d�|j|djd�|j|djd�Gd�dt�}	|�5|d��#1swY��xYw#t$r)}tj|j�}Yd}~��d}~wwxYw#1swYnxYwn1#|$r)}tj|j�}Yd}~nd}~wwxYw|jt
|�d�|j|djd�|j|djd	�Gd
�dt�}td�|d�fD�]}|jt|��
�5	|�5|�#1swYnxYw	|j|�d��nL#t|�$r;}|j||�tj|j�}Yd}~nd}~wwxYw|jt
|�d�|j|djd�|j|djd�ddd���#1swY��xYwy)Nc3�K�d��y�wr
r)r)rr�fz?ContextManagerTestCase.test_contextmanager_traceback.<locals>.f]�	�������rOr�test_contextmanager_traceback�1/0c��eZdZy)�RContextManagerTestCase.test_contextmanager_traceback.<locals>.RuntimeErrorSubclassNr(r)rr�RuntimeErrorSubclassrjlr+rrkrPzraise RuntimeErrorSubclass(42)c��eZdZy)�SContextManagerTestCase.test_contextmanager_traceback.<locals>.StopIterationSubclassNr(r)rr�StopIterationSubclassrmyr+rrn�spam��type� was suppressedzraise stop_exc)rYr`r8�
extract_tb�
__traceback__rZ�len�name�line�RuntimeError�
StopIteration�subTestrq�failr!)rrd�e�framesrkrn�stop_excs       rrgz4ContextManagerTestCase.test_contextmanager_traceback\s-��	�	�
�	�	;����!���
	
����V��a�(���������)H�I����������/�	�<�	�	;���*�2�.�.���� �	;��)�)�!�/�/�:�F��	;�������#�	;��)�)�!�/�/�:�F��	;��	
����V��a�(���������)H�I���������)I�J�	�M�	�
�&�!�!�&�)�
�H����4��>��2�<���&�������I�I��
�/�:�;��	�H�~�C��M�M�!�X�.�&�1�1�!�/�/�B�F��C��� � ��V��a�0�� � ������1P�Q�� � ������1A�B�3�2�2��	
s��B(�B�B(�C*�	C�B%�!B(�(	C�1C�C�C&�"C*�*D�/D�D�5J�7G#�>G�G
�G#�J�#H,�11H'�"J�'H,�,AJ�J	c��td��}|�}|j�|j|jtt	d�d��y)Nc3�K�d��y�wr
r)r)rr�wheezCContextManagerTestCase.test_contextmanager_no_reraise.<locals>.whee�rerf�foo)rYr"rHrr-)rr��ctxs   r�test_contextmanager_no_reraisez5ContextManagerTestCase.test_contextmanager_no_reraise�sD��	�	�
�	��f���
�
��������i��5�1A�4�H�Irc�V�td��}|�}|j�|jt�5|j	t
td�d�ddd�t
jd��r&|j|jj�yy#1swY�FxYw)Nc3�,K�	d��y#d��YyxYw�wr
r)r)rr�whoozOContextManagerTestCase.test_contextmanager_trap_yield_after_throw.<locals>.whoo�s����
���
��s��	���r�T��cpython)rYr"r,rxrr-r�check_impl_detailrH�gen�gi_suspended�rr�r�s   r�*test_contextmanager_trap_yield_after_throwzAContextManagerTestCase.test_contextmanager_trap_yield_after_throw�s���	�	�
�	�
�f���
�
��
�
�
�|�
,��L�L��I�e�$4�d�;�-��$�$�T�2����S�W�W�1�1�2�3�-�
,�s�!B�B(c��td��}|�}|jt�5|j�ddd�y#1swYyxYw)Nc3�K�y�wr
r)r)rrr�zFContextManagerTestCase.test_contextmanager_trap_no_yield.<locals>.whoo�s	�����s�)rYr,rxr"r�s   r�!test_contextmanager_trap_no_yieldz8ContextManagerTestCase.test_contextmanager_trap_no_yield�s@��	�	�
�	��f��
�
�
�|�
,��M�M�O�-�
,�
,�s�A�Ac�<�td��}|�}|j�|jt�5|j	ddd�ddd�tjd��r&|j|jj�yy#1swY�FxYw)Nc3�K�d��d��y�wr
r)r)rrr�zJContextManagerTestCase.test_contextmanager_trap_second_yield.<locals>.whoo�s��������
Tr�)
rYr"r,rxrrr�rHr�r�r�s   r�%test_contextmanager_trap_second_yieldz<ContextManagerTestCase.test_contextmanager_trap_second_yield�s}��	�	�
�	��f���
�
��
�
�
�|�
,��L�L��t�T�*�-��$�$�T�2����S�W�W�1�1�2�3�-�
,�s�B�Bc���td��}|�}|j�|jt�5|j	t
dd�ddd�y#1swYyxYw)Nc3�<K�	d��y#t$rt�wxYw�wr
)rx�SyntaxErrorr)rrr�zGContextManagerTestCase.test_contextmanager_non_normalised.<locals>.whoo�s"����
"����
"�!�!�
"�s��	���)rYr"r,r�rrxr�s   r�"test_contextmanager_non_normalisedz9ContextManagerTestCase.test_contextmanager_non_normalised�sP��	�	"�
�	"��f���
�
��
�
�
�{�
+��L�L��t�T�2�,�
+�
+�s�A�A#c����g�t��fd��}|�5}�j�dg��j|d��j|�td��#1swYnxYw�j�gd��y)Nc3���K��jd�	d��y#t$r<}�j|jd��j�gd��Yd}~yd}~wwxYw�w)NrOrPrrX)rSr`rrZ)r|rrUs ��rrVzAContextManagerTestCase.test_contextmanager_except.<locals>.woohoo�sR������L�L��O�
6����$�
6����Q�V�V�A�Y�'�� � ���5�5��
6�s*�A#��A#�	A �2A�A#�A � A#rOrPrQrX)rYrZrSr`r[s`  @r�test_contextmanager_exceptz1ContextManagerTestCase.test_contextmanager_except�su�����	�	6�
�	6��X�����U�Q�C�(����Q��#��L�L��O�#�C�(�(�	�X��
	
�����-s�AA�A&c�t�td��}Gd�dt�}td�|d�fD](}|jt|���5	|�5|�y#1swYnxYw	|j	|�d��n(#t
$r}|j
||�Yd}~nd}~wwxYwddd��#1swY��xYw)Nc3�K�d��y�wr
r)r)rrrVzJContextManagerTestCase.test_contextmanager_except_stopiter.<locals>.woohoo�rerfc��eZdZy)�YContextManagerTestCase.test_contextmanager_except_stopiter.<locals>.StopIterationSubclassNr(r)rrrnr��r+rrnrorprr)rYryrzrqr{�	Exceptionr!)rrVrnr~�exs     r�#test_contextmanager_except_stopiterz:ContextManagerTestCase.test_contextmanager_except_stopiter�s���	�	�
�	�	�M�	�'�v�.�0E�f�0M�N�H����4��>��2�<���&��	O�"����
�I�I��
�/�:�;��!�0��M�M�"�h�/�/��0��	3�2�2�sH�
B.�A=�A�A$� A=�(B.�=	B"�B�B.�B"�"B.�.B7	c���d}i}t|||�|d}td�}	|�5|�#1swYnxYw	|jd�y#t$r}|j	||�Yd}~yd}~wwxYw)Nztfrom __future__ import generator_stop
from contextlib import contextmanager
@contextmanager
def woohoo():
    yield
rVrozStopIteration was suppressed)�execryr{r�r!)r�code�localsrVr~r�s      r�!test_contextmanager_except_pep479z8ContextManagerTestCase.test_contextmanager_except_pep479�s{�������T�6�6�"���!�� ��(��	6���������

�I�I�4�5���	(��M�M�"�h�'�'��	(�s$�A�-�6�A�	A1�A,�,A1c�X�td��}	|�5t�#1swYnxYwnt#t$rh}|jt	|�t
�|j
|jdd�|j|jt�Yd}~nd}~wwxYw	|�5td��#1swYyxYw#t$rc}|jt	|�t�|j
|jdd�|j|j�Yd}~yd}~wwxYw)Nc3�PK�	d��y#t$r}td�|�d}~wwxYw�w)N�issue29692:Chained�r�rx��excs r�test_issue29692zoContextManagerTestCase.test_contextmanager_do_not_unchain_non_stopiteration_exceptions.<locals>.test_issue29692s.����
B����
B�"�#7�8�c�A��
B�s�&�	�&�	#��#�&rr�zissue29692:Unchained)rYr`r�r!rqrxrZr�assertIsInstance�	__cause__ry�assertIsNone)rr�r�s   r�?test_contextmanager_do_not_unchain_non_stopiteration_exceptionszVContextManagerTestCase.test_contextmanager_do_not_unchain_non_stopiteration_exceptionss���	�	B�
�	B�
	C� �"�'�'�#�"��"���	C��M�M�$�r�(�L�1����R�W�W�Q�Z�)=�>��!�!�"�,�,�0A�B�B��	C��
	,� �"�#�$:�;�;�#�"���	,��M�M�$�r�(�M�2����R�W�W�Q�Z�)?�@����b�l�l�+�+��	,�sR�)��%�)�	B�AB�B�B=�%B1�1B:�6B=�:B=�=	D)�AD$�$D)c�<�td��}|jt�5|�5ddzddd�ddd�|jt�5|�5t�#1swY�5xYw#1swY�9xYw#1swYnxYw	ddd�y#1swYyxYw)Nc3�VK�	d��y#t$r}td|���|�d}~wwxYw�w)Nzcaught r�r�s rrVzLContextManagerTestCase.test_contextmanager_wrap_runtimeerror.<locals>.woohoos0����
=����
=�"�W�S�E�?�3��<��
=�s�)�	�)�	&�!�&�)rOr)rYr,rxry�rrVs  r�%test_contextmanager_wrap_runtimeerrorz<ContextManagerTestCase.test_contextmanager_wrap_runtimeerrors|��	�	=�
�	=��
�
�|�
,����A���-��
�
�}�
-���#�#����-�
,������.�
-�
-�s?�A0�A$�A0�B�A<�$A-	�)A0�0A9�<B	�B�Bc�<�d�}t|d��d���}|S)Nc����fd�}|S)Nc�R���j�D]\}}t|||��|Sr
)�items�setattr)�func�k�v�kws   �r�decoratezXContextManagerTestCase._create_contextmanager_attribs.<locals>.attribs.<locals>.decorate-s(����8�8�:�C�A�a��D��1�%�&��rr))r�r�s` r�attribszFContextManagerTestCase._create_contextmanager_attribs.<locals>.attribs,s���
��Or�bar)r�c3�K�d��y�w)�Whee!Nr))ros r�bazzBContextManagerTestCase._create_contextmanager_attribs.<locals>.baz2s����
�rf�rY)rr�r�s   r�_create_contextmanager_attribsz5ContextManagerTestCase._create_contextmanager_attribs+s/��	�
�	�U�	�	�
�
�	��
rc��|j�}|j|jd�|j|jd�y)Nr�r�)r�rZrr��rr�s  r�test_contextmanager_attribsz2ContextManagerTestCase.test_contextmanager_attribs9s8���1�1�3��������e�,�������%�(rc�\�|j�}|j|jd�y�Nr��r�rZ�__doc__r�s  r�test_contextmanager_doc_attribz5ContextManagerTestCase.test_contextmanager_doc_attrib>s$���1�1�3��������g�.rc�h�|j�d�}|j|jd�yr�r�r�s  r�*test_instance_docstring_given_cm_docstringzAContextManagerTestCase.test_instance_docstring_given_cm_docstringCs+��3�d�1�1�3�D�9��������g�.rc��td��}|dddd��5}|j|d�ddd�y#1swYyxYw)Nc3�K�||||f��y�wr
r)�rr�r�kwdss    rrVz4ContextManagerTestCase.test_keywords.<locals>.woohooJs������t�T�*�*�r����!�,r�)r�r�r�r��rYrZ)rrV�targets   r�
test_keywordsz$ContextManagerTestCase.test_keywordsHsA��	�	+�
�	+�
��"�2�B�
7�6����V�%5�6�8�
7�
7�s�5�>c���Gd�d�}t�fd��}||�|���5	ddd�y#1swYyxYw)Nc��eZdZy)�0ContextManagerTestCase.test_nokeepref.<locals>.ANr(r)rr�Ar�Qr+rr�c3���K�tj|�}tj|�}tj��j	|���j	|��d��y�wr
)�weakref�refr�
gc_collectr�)�a�brs  �rrVz5ContextManagerTestCase.test_nokeepref.<locals>.woohooTsP��������A��A����A��A���� ����a�c�"����a�c�"��s�A0A3�r�r�)rr�rVs`  r�test_nokeeprefz%ContextManagerTestCase.test_nokeeprefPs@���	�	�
�	�
�	��A�C�1�3�
�� �
�
�s	�9�Ac�J�td��}|jt�5|�ddd�|jt�5|dd�ddd�|jt�5|d��ddd�y#1swY�XxYw#1swY�=xYw#1swYyxYw)Nc3�K�d��y�wr
r)�r�r�s  rrVz8ContextManagerTestCase.test_param_errors.<locals>.woohoobrerf��r�)rYr,r-r�s  r�test_param_errorsz(ContextManagerTestCase.test_param_errorsas~��	�	�
�	��
�
�y�
)��H�*�
�
�
�y�
)��1�a�L�*�
�
�
�y�
)��Q�K�*�
)�	*�
)��
)�
)��
)�
)�s#�B�
B
�.
B�B
�
B�B"c������d�d�t���fd��}|���fd������j�d��j�d�y)Nrc3�\�K��dz
��}�dz
�d���dz��j�|�y�w�NrO)rZ)�before�depth�ncolsrs ���rrVz5ContextManagerTestCase.test_recursive.<locals>.woohoops<�����
�Q�J�E��F��Q�J�E���Q�J�E����U�F�+�s�),c� ���dkr��yy)N�
r))r��	recursives��rr�z8ContextManagerTestCase.test_recursive.<locals>.recursive{s����r�z���rr�r�)rrVr�r�r�s` @@@r�test_recursivez%ContextManagerTestCase.test_recursivems\�������	�	,�
�	,�
��	�
�	�	�������#������"rN)rrrr]rargr�r�r�r�r�r�r�r�r�r�r�r�r�requires_docstringsr�r�r�r�r�r�r)rrrKrK<s���.�.�"0C�dJ�
3��3�3�.�"<�$6�*,�.$�&�)�

� � �/�!�/�
� � �/�!�/�7��"
�#rrKc�<�eZdZejd��Zd�Zd�Zy)�ClosingTestCasec�r�tj}td�}|j|j|�yr
)�closingr�rZ�r�cm_docstring�objs   r�test_instance_docsz"ClosingTestCase.test_instance_docs�s*�������d�m��������l�3rc����g�G�fd�d�}|�}|j�g�t|�5}|j||�ddd�|j�dg�y#1swY�xYw)Nc���eZdZ�fd�Zy)�'ClosingTestCase.test_closing.<locals>.Cc�(���jd�yr�rR�rrUs �r�closez-ClosingTestCase.test_closing.<locals>.C.close��������Q�rN�rrrrrTs�r�Cr�����
 rrrO)rZr��rrr\�yrUs    @r�test_closingzClosingTestCase.test_closing�sc�����	 �	 �
�C�������#�
�Q�Z�1����Q��"��������$��Z�s�A#�#A,c�<��g�G�fd�d�}|�}|j�g�|jt�5t|�5}|j||�ddzddd�ddd�|j�dg�y#1swY�%xYw#1swY�)xYw)Nc���eZdZ�fd�Zy)�-ClosingTestCase.test_closing_error.<locals>.Cc�(���jd�yr�rRrs �rrz3ClosingTestCase.test_closing_error.<locals>.C.close�r	rNr
rTs�rrr�rrrrOr)rZr,r`r�r
s    @r�test_closing_errorz"ClosingTestCase.test_closing_error�s������	 �	 �
�C�������#�
�
�
�0�
1����q�� � ��A�&��A���2�	
������$����2�
1�s#�B�
B�"B�B	�B�BN)rrrrr�rrrr)rrr�r��s$��� � �4�!�4�	%�%rr�c��eZdZd�Zy)�NullcontextTestCasec��Gd�d�}|�}t|�5}|j||�ddd�y#1swYyxYw)Nc��eZdZy)�/NullcontextTestCase.test_nullcontext.<locals>.CNr(r)rrrr�r+rr)�nullcontextr!)rr�c�c_ins    r�test_nullcontextz$NullcontextTestCase.test_nullcontext�s4��	�	�
�C��
��^�t��M�M�$��"��^�^�s	�9�AN)rrrrr)rrrr�s��#rrc��eZdZd�Zy)�FileContextTestCasec��tj�}	t|dd��5}|j|j�|jd�ddd�|j
j�|jt�5t|dd��5}|j|j�|j|j�d�ddzddd�ddd�|j
|j�tj|�y#1swY��xYw#1swY�NxYw#1swY�RxYw#tj|�wxYw)N�wzutf-8)�encodingzBooh
�rrOr)
�tempfile�mktemp�openrH�closed�writerFr,r`rZ�readr�unlink)r�tfnrds   r�testWithOpenz FileContextTestCase.testWithOpen�s����o�o���	"��c�3��1�Q�� � ����*�����!�2�
�O�O�A�H�H�%��"�"�#4�5��#�s�W�5���$�$�Q�X�X�.��$�$�Q�V�V�X�x�8���E�6�6�

�O�O�A�H�H�%����S�!�2�1��
6�5��6�5��
���S�!�sS�D>�-D�8D>�	D2�AD&�D2�!#D>�D#�D>�&D/	�+D2�2D;�7D>�>EN)rrrr,r)rrrr�s��"rrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�LockContextTestCasec��|j|��|5|j|��ddd�|j|��|jt�5|5|j|��ddzddd�ddd�|j|��y#1swY�zxYw#1swY�4xYw#1swY�8xYw�NrOr)rHrFr,r`)r�lock�lockeds   r�boilerPlatezLockContextTestCase.boilerPlate�s��������"�
��O�O�F�H�%�������"�
�
�
�0�
1�������)��A���2�	
�����"��T�����2�
1�s/�B)�#C�&B5�C�)B2�5B>	�:C�C
c�d�tj�}|j||j�yr
)�	threading�Lockr3r2�rr1s  r�testWithLockz LockContextTestCase.testWithLock�s"���~�~�������t�{�{�+rc�d�tj�}|j||j�yr
)r5�RLockr3�	_is_ownedr7s  r�
testWithRLockz!LockContextTestCase.testWithRLock�s"����� ������t�~�~�.rc�\��tj���fd�}|j�|�y)Nc�$���j�Sr
)r;�r1s�rr2z5LockContextTestCase.testWithCondition.<locals>.locked�s����>�>�#�#r)r5�	Conditionr3�rr2r1s  @r�testWithConditionz%LockContextTestCase.testWithCondition�s&����"�"�$��	$�����v�&rc�\��tj���fd�}|j�|�y)Nc�J���jd�r�j�yy�NFT��acquire�releaser?s�rr2z5LockContextTestCase.testWithSemaphore.<locals>.locked������|�|�E�"������r)r5�	Semaphorer3rAs  @r�testWithSemaphorez%LockContextTestCase.testWithSemaphore�s(����"�"�$��	�	
����v�&rc�\��tj���fd�}|j�|�y)Nc�J���jd�r�j�yyrErFr?s�rr2z<LockContextTestCase.testWithBoundedSemaphore.<locals>.locked�rIr)r5�BoundedSemaphorer3rAs  @r�testWithBoundedSemaphorez,LockContextTestCase.testWithBoundedSemaphore�s(����)�)�+��	�	
����v�&rN)	rrrr3r8r<rBrKrOr)rrr.r.�s ��	#�,�/�'�'�'rr.c�(�eZdZdZdZdZdZd�Zd�Zy)�	mycontextz9Example decoration-compatible context manager for testingFNc��d|_|S�NT��startedr3s rr"zmycontext.__enter__�s������rc�(�||_|jSr
)r��catch�rr�s  rrzmycontext.__exit__�s������z�z�r)	rrrr�rUr�rWr"rr)rrrQrQ�s��C��G�
�C��E��rrQc�f�eZdZejd��Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zy)�TestContextDecoratorc�p�tj}t�}|j|j|�yr
)rQr�rZr�s   rrz'TestContextDecorator.test_instance_docss*��!�(�(���k��������l�3rc���t�}|5}|j||�|j|j�ddd�|j	|j
d�y#1swY�&xYw)N�NNN)rQr!rFrUrZr�)r�context�results   r�test_contextdecoratorz*TestContextDecorator.test_contextdecorator
sP���+��
���M�M�&�'�*��O�O�G�O�O�,��	
������&8�9�	�W�s�.A � A)c���t�}|jtd�5|5td��#1swYnxYw	ddd�n#1swYnxYw|j|j�|j|jdt�t�}d|_|5td��#1swYnxYw|j|j�|j|jdt�y)Nr�rT)rQ�assertRaisesRegex�	NameError�assertIsNotNoner�r!rW)rr^s  r�$test_contextdecorator_with_exceptionz9TestContextDecorator.test_contextdecorator_with_exceptions����+��
�
#�
#�I�u�
5����&�&�����6�
5�
5��	
���W�[�[�)��
�
�g�k�k�!�n�i�0��+����
�
��E�"�"��W�����W�[�[�)��
�
�g�k�k�!�n�i�0s$�A�0�9	�A�A�#B/�/B8c�x���t�����fd��}|��j�jd�y)Nc�r���j�j��j�j�yr
�r�r�rFrU�r^rs��r�testz1TestContextDecorator.test_decorator.<locals>.test'�%������g�k�k�*��O�O�G�O�O�,rr])rQrZr��rrjr^s` @r�test_decoratorz#TestContextDecorator.test_decorator$s8����+��	�	-�
�	-�	
��������&8�9rc����t�����fd��}�jtd�5|�ddd��j�j��j�jdt�y#1swY�HxYw)Nc����j�j��j�j�t	d��)Nr�)r�r�rFrUrcris��rrjz@TestContextDecorator.test_decorator_with_exception.<locals>.test2s0������g�k�k�*��O�O�G�O�O�,��E�"�"rr�r)rQrbrcrdr�r!rls` @r�test_decorator_with_exceptionz2TestContextDecorator.test_decorator_with_exception/si����+��	�	#�
�	#�
�
#�
#�I�u�
5��F�6����W�[�[�)��
�
�g�k�k�!�n�i�0�6�
5�s�A=�=Bc���t��G�fd�dt�}|�}|jdd�|j|jd�|j|j
d�|j|jd�|�}|jddd�|j|jd�|j|j
d�|j|jd�|�}|jdd��|j|jd�|j|j
d�y)	Nc�"��eZdZW�dd��Zy)�9TestContextDecorator.test_decorating_method.<locals>.TestNc�.�||_||_||_yr
)r�r�r)rr�r�rs    r�methodz@TestContextDecorator.test_decorating_method.<locals>.Test.methodCs����������rr
)rrrru)r^s�r�TestrsAs���
�
��
rrvrO�r�r�rr�)rQ�objectrurZr�r�r)rrvrjr^s   @r�test_decorating_methodz+TestContextDecorator.test_decorating_method>s�����+��	�6�	��v�����A�q���������#��������#��������&��v�����C��c�"��������%��������%��������%��v�����a�1����������#��������#rc��Gd�dt�}|jtd�5|�5	ddd�ddd�y#1swY�xYw#1swYyxYw)Nc��eZdZd�Zd�Zy)�7TestContextDecorator.test_typo_enter.<locals>.mycontextc��yr
r)r3s r�	__unter__zATestContextDecorator.test_typo_enter.<locals>.mycontext.__unter__^���rc��yr
r)rXs  rrz@TestContextDecorator.test_typo_enter.<locals>.mycontext.__exit__`rrN)rrrr~rr)rrrQr|]���
�
rrQ�the context manager��ContextDecoratorrbr-�rrQs  r�test_typo_enterz$TestContextDecorator.test_typo_enter\sH��	�(�	��
#�
#�I�/D�
E�����F�
E����F�
E��!�A
�A�A
�A
	�A
�
Ac��Gd�dt�}|jtd�5|�5	ddd�ddd�y#1swY�xYw#1swYyxYw)Nc��eZdZd�Zd�Zy)�6TestContextDecorator.test_typo_exit.<locals>.mycontextc��yr
r)r3s rr"z@TestContextDecorator.test_typo_exit.<locals>.mycontext.__enter__jrrc��yr
r)rXs  r�__uxit__z?TestContextDecorator.test_typo_exit.<locals>.mycontext.__uxit__lrrN)rrrr"r�r)rrrQr�ir�rrQzthe context manager.*__exit__r�r�s  r�test_typo_exitz#TestContextDecorator.test_typo_exithsH��	�(�	��
#�
#�I�/N�
O�����P�
O����P�
O�r�c����Gd�dt�}Gd�d|t�}|�����fd��}|��j�jd�y)Nc� �eZdZdZdZd�Zd�Zy)�HTestContextDecorator.test_contextdecorator_as_mixin.<locals>.somecontextFNc��d|_|SrSrTr3s rr"zRTestContextDecorator.test_contextdecorator_as_mixin.<locals>.somecontext.__enter__ys��#����rc��||_yr
r�rXs  rrzQTestContextDecorator.test_contextdecorator_as_mixin.<locals>.somecontext.__exit__}�	����r)rrrrUr�r"rr)rr�somecontextr�us���G��C�
�
rr�c��eZdZy)�FTestContextDecorator.test_contextdecorator_as_mixin.<locals>.mycontextNr(r)rrrQr��r+rrQc�r���j�j��j�j�yr
rhris��rrjzATestContextDecorator.test_contextdecorator_as_mixin.<locals>.test�rkrr])rxr�rZr�)rr�rQrjr^s`   @r�test_contextdecorator_as_mixinz3TestContextDecorator.test_contextdecorator_as_mixintsU���		�&�		�	��%5�	��+��	�	-�
�	-�	
��������&8�9rc����t�fd��}g�|d���fd��}|d��j�gd��g�|d��j�gd��y)Nc3�Z�K��j|�d���jd�y�w)NrQrR)rrUs �rrVzETestContextDecorator.test_contextmanager_as_decorator.<locals>.woohoo�s!������L�L��O���L�L���rWrOc�N���j�dg��j|�yr�)rZrS)r\rrUs ��rrjzCTestContextDecorator.test_contextmanager_as_decorator.<locals>.test�s ������U�Q�C�(��L�L��Or�	something)rOr�rQ�something else)rOr�rQr�)rrVrjrUs`  @r� test_contextmanager_as_decoratorz5TestContextDecorator.test_contextmanager_as_decorator�sn���	�	�
�	�
��	���	�
�	�	
�[������ 5�6����
������ :�;rN)rrrrr�rr`rermrpryr�r�r�r�r)rrrZrZsG��� � �4�!�4�:�1�":�1�$�<	�	�:�0<rrZc��eZdZdZej
d��Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TestBaseExitStackNc��|jj}|j�}|j|j|�yr
)�
exit_stackr�rZr�s   rrz$TestBaseExitStack.test_instance_docs�s3�����.�.���o�o���������l�3rc�P�|j�5	ddd�y#1swYyxYwr
)r�r3s r�test_no_resourcesz#TestBaseExitStack.test_no_resources�s��
�_�_�
���
�
�s��%c����difdifdifdtd��fdtd��fdtd��fdtdd��fg}g��fd	�}|j�5}t|�D]o\}}|r|r|j|g|��i|��}n=|r|j|g|���}n'|r|j|fi|��}n|j|�}|j	||��q|j
D]s}|j	|dj|�|j|dj|j�|j|dj|j��u	ddd�|j�|�g�|j�5}|jt�5|jd�
�ddd�|jt�5|jjd�
�ddd�|jt�5|j|d��ddd�ddd�|j�g�y#1swY��xYw#1swY��xYw#1swY�mxYw#1swY�HxYw#1swY�LxYw)
Nr))rO)rOrwrO)�exampler��)r�callbackc�,���j||f�y)zTest metadata propagationNrR)rr�r_s  �r�_exitz.TestBaseExitStack.test_callback.<locals>._exit�s����M�M�4��,�'r)�argrw)r�r�)�dictr��reversedr�r!�_exit_callbacks�__wrapped__�assertNotEqualrr�r�rZr,r-)	r�expectedr��stackrr�rd�wrapperr_s	        @r�
test_callbackzTestBaseExitStack.test_callback�s$���
��H�
�2�J�
�B�K�
��a��!�
�4��?�#�
�D��O�$�
�D�a�!�,�-�
����	(��_�_�
�%�&�x�0�
��d��D�&����u�<�t�<�t�<�A��&����u�4�t�4�A��&����u�5��5�A����u�-�A��
�
�a��'�1�!�0�0���
�
�g�a�j�4�4�e�<��#�#�G�A�J�$7�$7����H��!�!�'�!�*�"4�"4�e�m�m�D�1��	
�����*���
�_�_�
�%��"�"�9�-����1��%�.��"�"�9�-����(�(�Q�(�/�.��"�"�9�-�����1��5�.��	
�����$�3�
��&.�-��-�-��-�-���
�sa�DH=�I-�I	�/I-�I�)I-�I!�I-�=I�	I	�I-�I	�I-�!I*	�&I-�-I6c�N���t���fd�}d�}�fd�}Gd�dt�}�j�5}|j|��j	|j
dd|�||�}|j|��j	|j
ddj|�|j|��j	|j
dd|�||�}|j|��j	|j
ddj|�|j|��j	|j
dd|�|j|��j	|j
dd|�ddzddd�y#1swYyxYw)	Nc�*���j|��yr
)r!)r6r��exc_tb�
exc_raisedrs   ��r�_expect_excz0TestBaseExitStack.test_push.<locals>._expect_exc�s����M�M�(�J�/rc��yrSr)��exc_detailss r�
_suppress_excz2TestBaseExitStack.test_push.<locals>._suppress_exc����rc�l���j|��j|��j|�yr
)r�)r6r�r�rs   �r�
_expect_okz/TestBaseExitStack.test_push.<locals>._expect_ok�s-������h�'����c�"����f�%rc��eZdZd�Zd�Zd�Zy)�+TestBaseExitStack.test_push.<locals>.ExitCMc��||_yr
��	check_exc)rr�s  r�__init__z4TestBaseExitStack.test_push.<locals>.ExitCM.__init__�s	��!*��rc�&�|jd�y)NzShould not be called!)r{r3s rr"z5TestBaseExitStack.test_push.<locals>.ExitCM.__enter__�s���	�	�1�2rc�"�|j|�yr
r��rr�s  rrz4TestBaseExitStack.test_push.<locals>.ExitCM.__exit__�s�������,rN�rrrr�r"rr)rr�ExitCMr��s��
+�
3�
-rr����rOr)r`rxr��pushr!r��__self__)rr�r�r�r�r��cmr�s`      @r�	test_pushzTestBaseExitStack.test_push�s^���&�
�	0�	�	&�	-�V�	-��_�_�
�%��J�J�z�"��M�M�%�/�/��3�A�6�
�C��
�#�B��J�J�r�N��M�M�%�/�/��3�A�6�?�?��D��J�J�}�%��M�M�%�/�/��3�A�6�
�F���$�B��J�J�r�N��M�M�%�/�/��3�A�6�?�?��D��J�J�{�#��M�M�%�/�/��3�A�6��D��J�J�{�#��M�M�%�/�/��3�A�6��D�
�a�C��
�
�s�EF�F$c���G�fd�dt�}g�|�}|j�5}|j�fd��}|j|�|j	|�|j|jddj|��jd�ddd�|j�gd��y#1swY�xYw)Nc�"��eZdZ�fd�Z�fd�Zy)�4TestBaseExitStack.test_enter_context.<locals>.TestCMc�(���jd�yr�rR)rr_s �rr"z>TestBaseExitStack.test_enter_context.<locals>.TestCM.__enter__������
�
�a� rc�(���jd�y�Nr�rR)rr�r_s  �rrz=TestBaseExitStack.test_enter_context.<locals>.TestCM.__exit__�r�rNr9�r_s�r�TestCMr��s
���
!�
!rr�c�(���jd�y)Nr�rRr�s�rr�z3TestBaseExitStack.test_enter_context.<locals>._exit�����
�
�a� rr�rOrw)rOrwr�r�)
rxr�r�rd�
enter_contextr!r�r�rSrZ)rr�r�r�r�r_s     @r�test_enter_contextz$TestBaseExitStack.test_enter_context�s����	!�V�	!���
�X��
�_�_�
�%�
�^�^�
!��
!�� � ��'�����#��M�M�%�/�/��3�A�6�?�?��D��M�M�!���	
�����.��
�s�A4B=�=Cc�F�Gd�d�}Gd�d�}Gd�d�}|j�5}|jtd�5|j|��ddd�|jtd�5|j|��ddd�|jtd�5|j|��ddd�|j	|j
�ddd�y#1swY��xYw#1swY�nxYw#1swY�ExYw#1swYyxYw)Nc��eZdZy)�FTestBaseExitStack.test_enter_context_errors.<locals>.LacksEnterAndExitNr(r)rr�LacksEnterAndExitr�r+rr�c��eZdZd�Zy)�?TestBaseExitStack.test_enter_context_errors.<locals>.LacksEnterc��yr
r))r�exc_infos  rrzHTestBaseExitStack.test_enter_context_errors.<locals>.LacksEnter.__exit__rrNrDr)rr�
LacksEnterr����
rr�c��eZdZd�Zy)�>TestBaseExitStack.test_enter_context_errors.<locals>.LacksExitc��yr
r)r3s rr"zHTestBaseExitStack.test_enter_context_errors.<locals>.LacksExit.__enter__rrNr@r)rr�	LacksExitr�r�rr�r�)r�rbr-r�rHr�)rr�r�r�r�s     r�test_enter_context_errorsz+TestBaseExitStack.test_enter_context_errors
s���	�	�	�	�	�	��_�_�
�%��'�'�	�3H�I��#�#�$5�$7�8�J��'�'�	�3H�I��#�#�J�L�1�J��'�'�	�3H�I��#�#�I�K�0�J����U�2�2�3��
�I�I��I�I��I�I���
�sS�D�C3�D�;C?�D�0D�#D�3C<	�8D�?D	�D�D	�D�D c���g�|j�5}|j�fd��}|j|�|j��j	d�ddd�|j�ddg�y#1swY�xYw)Nc�(���jd�yr�rRr�s�rr�z+TestBaseExitStack.test_close.<locals>._exit#r�rrwrO)r�r�rdrrSrZ)rr�r�r_s   @r�
test_closezTestBaseExitStack.test_close sq�����
�_�_�
�%�
�^�^�
!��
!�� � ��'��K�K�M��M�M�!��
�	
����!�Q��(��
�s�AA8�8Bc�J��g�|j�5}|j�fd��}|j|�|j�}�j	d�ddd��j	d�j�|j
�gd��y#1swY�?xYw)Nc�(���jd�yr�rRr�s�rr�z-TestBaseExitStack.test_pop_all.<locals>._exit.r�rrOrw)rOrwr�)r�r�rd�pop_allrSrrZ)rr�r��	new_stackr_s    @r�test_pop_allzTestBaseExitStack.test_pop_all+s������
�_�_�
�%�
�^�^�
!��
!�� � ��'��
�
��I��M�M�!��
�	�
�
�a�����������+��
�s�AB�B"c���|jt�5|j�5}|jd��ddzddd�ddd�y#1swY�xYw#1swYyxYw)Nc��y)NFr)r�s r�<lambda>z3TestBaseExitStack.test_exit_raise.<locals>.<lambda>;s��rrOr)r,r`r�r��rr�s  r�test_exit_raisez!TestBaseExitStack.test_exit_raise8sN��
�
�
�0�
1����"�e��
�
�-�.��!��#�2�
1�"�"��2�
1�s!�A�A�A�A	�A�A%c�|�|j�5}|jd��ddzddd�y#1swYyxYw)Nc��yrSr)r�s rr�z6TestBaseExitStack.test_exit_suppress.<locals>.<lambda>@���DrrOr�r�r�r�s  r�test_exit_suppressz$TestBaseExitStack.test_exit_suppress>s.��
�_�_�
�%��J�J�(�)�
�a�C��
�
�s�2�;c���d�}	|j�5}|j|t�ddzddd�|jt�t	j
|j�}dg|jzddgz}|j|D�cgc]}|j|jf��c}|�|j|jt�t	j
|jj�}|j|D�cgc]}|j|jf��c}dg�y#1swY��xYw#t$r
}|}Yd}~��d}~wwxYwcc}wcc}w)Nc��|�r
r)r�s r�	raise_exczBTestBaseExitStack.test_exit_exception_traceback.<locals>.raise_excI����IrrOr)�test_exit_exception_tracebackz with self.exit_stack() as stack:)�
_exit_wrapperzcallback(*args, **kwds))rz	raise exc)rrh)
r�r��
ValueErrorr�r8rsrt�callback_error_internal_framesrZrvrw�__context__r`)	rrr�r|r��	ve_framesr�rd�
zde_framess	         rrz/TestBaseExitStack.test_exit_exception_tracebackCsA��	�	����"�e����y�*�5��!��#�	
���c�:�.��(�(��):�):�;�	�
R�S��/�/�
0�
9�
'�
)�
)�	�	
���'0�1�y�!�a�f�f�a�f�f�
�y�1�8�	=�	
���c�o�o�/@�A��)�)�#�/�/�*G�*G�H�
����J�?�J�q�1�6�6�1�6�6�*�J�?�B�C�	E�'#�"���	��C��	��
2��@s9�E�D:�E�E �E%�:E�?E�	E�E�Ec	��Gd�d�}Gd�d�}Gd�d�}	|t�5|tt�5|�5|t�5ddzddd�ddd�ddd�ddd�|j	d	�|jd}|j|t�|j|jt�y#1swY�xxYw#1swY�|xYw#1swY��xYw#1swY��xYw#t$r�}|j|jt�|j|jjt�|j|jjj�Yd}~��d}~wwxYw)
Nc��eZdZd�Zd�Zd�Zy)�JTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExcc��||_yr
r�rXs  rr�zSTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExc.__init__gr�rc��|Sr
r)r3s rr"zTTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExc.__enter__ir4rc��|j�r
r�r�s  rrzSTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExc.__exit__ks���h�h�rNr�r)rr�RaiseExcr
fs��
�
�
rrc��eZdZd�Zd�Zd�Zy)�UTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExcWithContextc� �||_||_yr
)�outer�inner)rrrs   rr�z^TestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExcWithContext.__init__os��"��
�"��
rc��|Sr
r)r3s rr"z_TestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExcWithContext.__enter__rr4rc�>�	|j�#|j�xYwr
)rrr�s  rrz^TestBaseExitStack.test_exit_exception_chaining_reference.<locals>.RaiseExcWithContext.__exit__ts"��%��*�*�$��%��*�*�$�s��Nr�r)rr�RaiseExcWithContextrns��
#�
�
%rrc��eZdZd�Zd�Zy)�MTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.SuppressExcc��|Sr
r)r3s rr"zWTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.SuppressExc.__enter__{r4rc�$�|t|�_yrS)rq�
saved_detailsr�s  rrzVTestBaseExitStack.test_exit_exception_chaining_reference.<locals>.SuppressExc.__exit__}s��+6��T�
�(�rNr9r)rr�SuppressExcrzs��
�
rrrOr�0Expected IndexError, but no exception was raised)
�
IndexError�KeyError�AttributeErrorrr{r�rr�rr`)rrrrr��	inner_excs      r�&test_exit_exception_chaining_referencez8TestBaseExitStack.test_exit_exception_chaining_referencecs-��	�	�
	%�
	%�	�	�	J��*�%�(��>�B�$��%�j�1���E�2�'�C�&�
�I�I�H�I��-�-�a�0�	����i��4����i�3�3�5F�G�2�1��'���C�B��&�%��
�	G��!�!�#�/�/�8�<��!�!�#�/�/�"=�"=�~�N����c�o�o�9�9�E�E�F�F��		G�sv�D�C4�C(�
C�C	�C�!C(�)C4�1D�C
�C�C%�!C(�(C1	�-C4�4C=�9D�	F�	A9F�Fc���d�}d��fd�}	|j�5}|j|t�|j|t�|j|t�|j|�|j|t�ddzddd�|jd��d}|j|t�|j|jt�y#1swY�VxYw#t$r�}|j|jt�|j|jjt�|j|jjj�Yd}~��d}~wwxYw)Nc��|�r
r)r�s rrzATestBaseExitStack.test_exit_exception_chaining.<locals>.raise_exc�rrc�
��|�yrSr))r�rs �r�suppress_exczDTestBaseExitStack.test_exit_exception_chaining.<locals>.suppress_exc�s���'�M�rrOrr )r�r�r!r"r#r�rr{r�rr�r`)rrr)r�r�r$rs      @r�test_exit_exception_chainingz.TestBaseExitStack.test_exit_exception_chaining�s!���	��
�	�
	J����"�e����y�*�5����y�(�3����y�.�9��
�
�<�(����y�*�5��A��
#�
�I�I�H�I�!�!�$�	����i��4����i�3�3�5F�G�##�"���	G��!�!�#�/�/�8�<��!�!�#�/�/�"=�"=�~�N����c�o�o�9�9�E�E�F�F��		G�s0�C-�A/C!�C-�!C*�&C-�-	E9�6A9E4�4E9c�|����Gd�dt��t�fd���t��fd��}�|fD]%}�j�5	|�5t��y#1swYnxYw	�j	d�n-#�$r%}�j|j�Yd}~nd}~wwxYwddd��~#1swY��xYw)Nc��eZdZy)�PTestBaseExitStack.test_exit_exception_explicit_none_context.<locals>.MyExceptionNr(r)rr�MyExceptionr-�r+rr.c3�^�K�	d��y#t$r��}	|�#d|_wxYwwxYw�wr
)�
BaseExceptionr)r�r.s �r�my_cmzJTestBaseExitStack.test_exit_exception_explicit_none_context.<locals>.my_cm�s7�����
+��� �
+�!�m��+��I��&*�C�O��
+�s �-�
�-�*��	&�*�-c3��K��j�5}|j���|��ddd�y#1swYyxYw�wr
)r�r�)r�r1rs ��r�my_cm_with_exit_stackzZTestBaseExitStack.test_exit_exception_explicit_none_context.<locals>.my_cm_with_exit_stack�s3��������"�e��#�#�E�G�,���#�"�"�s�A�8�	A�A�Ar )r�rYrzr!r{r�r)rr3r�r�r.r1s`   @@r�)test_exit_exception_explicit_none_contextz;TestBaseExitStack.test_exit_exception_explicit_none_context�s����	�)�	�
�	+�
�	+�
�	�
�	�
�/�0�B�����R���(�l�*�	1�����
�I�I�P�Q��#�7��%�%�c�o�o�6�6��7��	 ���sH�B2�	A<�A�A&�"A<�*B2�<B&�B!�B2�!B&�&B2�2B;	c�f�d�}d�}	|j�5}|jd��|j|t�ddd�|jd�	|j�5}|j|t�|j|�|j|t�ddd�|jd�y#1swY��xYw#t$r }|j|t�Yd}~��d}~wwxYw#1swY�SxYw#t$r }|j|t�Yd}~yd}~wwxYw)Nc��|�r
r)r�s rrzHTestBaseExitStack.test_exit_exception_non_suppressing.<locals>.raise_exc�rrc��yrSr)r�s rr)zKTestBaseExitStack.test_exit_exception_non_suppressing.<locals>.suppress_exc�r�rc��yr
r)r)rrr�zGTestBaseExitStack.test_exit_exception_non_suppressing.<locals>.<lambda>�s��trr z.Expected KeyError, but no exception was raised)r�r�r!r{r�r�r"r�)rrr)r�r�s     r�#test_exit_exception_non_suppressingz5TestBaseExitStack.test_exit_exception_non_suppressing�s���	�	�	J����"�e����|�,����y�*�5�#�
�I�I�H�I�	H����"�e����y�(�3��
�
�<�(����y�*�5�#�
�I�I�F�G�!#�"���	3��!�!�#�z�2�2��	3��#�"���	1��!�!�#�x�0�0��	1�s^�C�)C�C�D�+>C;�)D�C�C�	C8�C3�3C8�;D�D�	D0�D+�+D0c���td��}td�}td�}td�}td�}	|j�5}|j||��|j||��|j||��|�#1swYyxYw#t$r�}|j	||�|j	|j
|�|j	|j
j
|�|j	|j
j
j
|�|j
|j
j
j
j
�Yd}~yd}~wwxYw)Nc3�$K�	d��|�#|�xYw�wr
r)r�s r�gets_the_context_rightzZTestBaseExitStack.test_exit_exception_with_correct_context.<locals>.gets_the_context_right�s����
���	��c�	�s��
��
�rOrwr�r�)rYr�r�r�r!rr�)rr<�exc1�exc2�exc3�exc4r�r�s        r�(test_exit_exception_with_correct_contextz:TestBaseExitStack.test_exit_exception_with_correct_context�s-��	�	�
�	���|����|����|����|��
	L����"�e��#�#�$:�4�$@�A��#�#�$:�4�$@�A��#�#�$:�4�$@�A��
�	#�"��
�	L��M�M�#�t�$��M�M�#�/�/�4�0��M�M�#�/�/�5�5�t�<��M�M�#�/�/�5�5�A�A�4�H�������2�2�>�>�J�J�
L�
L��	L�s1�B�
AB�B�B�B�	E.�'B=E)�)E.c�2�d�}td�}td�}td�}td�}td�}	|j�5}|j|||�|j|||�|�#1swYyxYw#t$�r}|j||�|j|j|�|j|jj|�|j|jjj|�|j|jjjj|�|j|jjjjj�Yd}~yd}~wwxYw)Nc��	|�#|�xYwr
r))r$�	outer_excs  r�raise_nestedzQTestBaseExitStack.test_exit_exception_with_existing_context.<locals>.raise_nesteds��
 ������s��rOrwr�r�r�)r�r�r�r!rr�)	rrEr=r>r?r@�exc5r�r�s	         r�)test_exit_exception_with_existing_contextz;TestBaseExitStack.test_exit_exception_with_existing_contexts;��	 �
��|����|����|����|����|��
	Q����"�e����|�T�4�8����|�T�4�8��
�#�"���	Q��M�M�#�t�$��M�M�#�/�/�4�0��M�M�#�/�/�5�5�t�<��M�M�#�/�/�5�5�A�A�4�H��M�M����,�,�8�8�D�D�d�
L�������+�+�7�7�C�C�O�O�
Q�
Q��	Q�s0�B�)A5�5A>�:B�>B�
F�DF�Fc���d�}	|j�5}|j|�ddzddd�y#1swYyxYw#t$r}|jd�Yd}~yd}~wwxYw)Nc��yrSr)r�s rr)zDTestBaseExitStack.test_body_exception_suppress.<locals>.suppress_exc+r�rrOrz%Expected no exception, got IndexError)r�r�r!r{)rr)r�r�s    r�test_body_exception_suppressz.TestBaseExitStack.test_body_exception_suppress*sX��	�	?����"�e��
�
�<�(��!��#�"�"���	?��I�I�=�>�>��	?�s.�A�5�A�>�A�A�	A%�
A � A%c��|j�5}|jd��|jd��|jd��ddd�y#1swYyxYw)Nc��yrSr)r�s rr�zITestBaseExitStack.test_exit_exception_chaining_suppress.<locals>.<lambda>6r�rc��ddzSr0r)r�s rr�zITestBaseExitStack.test_exit_exception_chaining_suppress.<locals>.<lambda>7s��A�a�Crc��idSr�r)r�s rr�zITestBaseExitStack.test_exit_exception_chaining_suppress.<locals>.<lambda>8s��B�q�Err�r�s  r�%test_exit_exception_chaining_suppressz7TestBaseExitStack.test_exit_exception_chaining_suppress4sA��
�_�_�
�%��J�J�(�)��J�J�'�(��J�J�)�*��
�
�s�7A�Ac��|j�5}td�D]}|jt��	ddd�y#1swYyxYw)Ni')r��ranger��int)rr��is   r�test_excessive_nestingz(TestBaseExitStack.test_excessive_nesting:s4��
�_�_�
�%��5�\�����s�#�"��
�
�s�&A�A
c�j�Gd�dt�}|�}t�|_t�|_|j�}|j	t
d�5|j
|�ddd�|j|�|j|jdd|�y#1swY�=xYw)Nc��eZdZy)�7TestBaseExitStack.test_instance_bypass.<locals>.ExampleNr(r)rr�ExamplerWA��rrXr�r�rO)
rxr"rr�rbr-r�r�r!r�)rrXr�r�s    r�test_instance_bypassz&TestBaseExitStack.test_instance_bypass@s���#�f�#�
�Y���x����h������!��
�
#�
#�I�/D�
E�����#�F�
�
�
�2���
�
�e�+�+�B�/��2�B�7�F�
E�s�B)�)B2c���Gd�dt��Gd�dt�}t�fd��}td��}|j��5}|j	�5}|j|��|j|��|d��#1swYnxYw	ddd�n#1swYnxYwj}|j|��|j|j|�|j|jj�|j|jj�|j|j|j�y)Nc��eZdZy)�ITestBaseExitStack.test_dont_reraise_RuntimeError.<locals>.UniqueExceptionNr(r)rr�UniqueExceptionr]MrYrr^c��eZdZy)�LTestBaseExitStack.test_dont_reraise_RuntimeError.<locals>.UniqueRuntimeErrorNr(r)rr�UniqueRuntimeErrorr`NrYrrac3�L�K�	d��y#t$r}�d�|�d}~wwxYw�w)NrOz
new exception�r�)r�r^s �r�secondz@TestBaseExitStack.test_dont_reraise_RuntimeError.<locals>.secondPs0�����
@�����
@�%�o�6�C�?��
@�s�$�
�$�	!�	�!�$c3�<K�	d��y#t$r}|�d}~wwxYw�wr�rcr�s r�firstz?TestBaseExitStack.test_dont_reraise_RuntimeError.<locals>.firstWs$����
�����
��	��
�s��	��	���zplease no infinite loop.)r�rxrYr,r�r��	exceptionr�rr�r�r!)rrardrf�err_ctx�es_ctxr�r^s       @r�test_dont_reraise_RuntimeErrorz0TestBaseExitStack.test_dont_reraise_RuntimeErrorKs���.�i�.�4��4�	�	@�
�	@�
�	�
�	��
�
��
/�7����"�f��$�$�V�X�.��$�$�U�W�-�(�)C�D�D�#�"��"�0�
/�
/���������c�?�3����c�o�o�/A�B����#�/�/�5�5�6����#�/�/�3�3�4��
�
�c�m�m�S�_�_�5s�B'�5B�B	�B'�'B0)rrrr�rr�rr�r�r�r�r�r�r�r�r�rr%r*r4r9rArGrJrOrTrZrjr)rrr�r��s����J�� � �4�!�4��'%�R �D/�&4�&	)�,���
E�@.H�`H�> R�DH�6L�>Q�8?�+�$�	8� 6rr�c��eZdZeZddgZy)�
TestExitStack)rzraise exc_details[1])rzif cb(*exc_details):N)rrr�	ExitStackr�rr)rrrlrlns���J�,�,�&�"rrlc�V�eZdZdZdZejd��Zd�Zd�Z	d�Z
d�Zd�Zy)�TestRedirectStreamNc��|jj}|jd�}|j|j|�yr
)�redirect_streamr�rZr�s   rrz%TestRedirectStream.test_instance_docs{s9���+�+�3�3���"�"�4�(��������l�3rc��tt|j�}|jd�|j	tt|j�|�yr
)�getattr�sys�orig_streamrqr!)r�orig_stdouts  r�test_no_redirect_in_initz+TestRedirectStream.test_no_redirect_in_init�s=���c�4�#3�#3�4�����T�"��
�
�g�c�4�#3�#3�4�k�Brc��tj�}d}tt|j�}|j|�5t
|tt|j���ddd�|jtt|j�|�|j�j�}|j||�y#1swY�dxYw)Nz<Consider an API like help(), which prints directly to stdout��file)�io�StringIOrsrtrurq�printr!�getvalue�striprZ)rrd�msgrv�ss     r�test_redirect_to_string_ioz-TestRedirectStream.test_redirect_to_string_io�s����K�K�M��L���c�4�#3�#3�4��
�
!�
!�!�
$��#�G�C��)9�)9�:�;�%��
�
�g�c�4�#3�#3�4�k�B�
�J�J�L��� ������C� �	%�
$�s�&C�Cc��tj�}|j|�5}|j||�ddd�y#1swYyxYwr
)r{r|rqr!)rrd�enter_results   r�test_enter_result_is_targetz.TestRedirectStream.test_enter_result_is_target�s7���K�K�M��
�
!�
!�!�
$���M�M�,��*�%�
$�
$�s�A�Ac	��tj�}|j|�}tt|j
�}|5t
ddtt|j
���ddd�|5t
dtt|j
���ddd�|jtt|j
�|�|j�}|j|d�y#1swY��xYw#1swY�bxYw�N�Hello� )�endrzzWorld!ryz
Hello World!
�
r{r|rqrsrtrur}r!r~rZ�rrd�
write_to_frvr�s     r�test_cm_is_reusablez&TestRedirectStream.test_cm_is_reusable�s����K�K�M���)�)�!�,�
��c�4�#3�#3�4��
��'�s���d�6F�6F�)G�H��
��(���d�.>�.>�!?�@���
�
�g�c�4�#3�#3�4�k�B�
�J�J�L������,�-�
�Z��
�Z�s�'C.�3&C:�.C7�:Dc	��tj�}|j|�}tt|j
�}|5t
ddtt|j
���|5t
dtt|j
���ddd�ddd�|jtt|j
�|�|j�}|j|d�y#1swY�^xYw#1swY�bxYwr�r�r�s     r�test_cm_is_reentrantz'TestRedirectStream.test_cm_is_reentrant�s����K�K�M���)�)�!�,�
��c�4�#3�#3�4��
��'�s���d�6F�6F�)G�H���h�W�S�$�2B�2B�%C�D���	
�
�
�g�c�4�#3�#3�4�k�B�
�J�J�L������,�-�	����Z�s$�)C:�+&C.�C:�.C7	�3C:�:D)
rrrrqrurr�rrwr�r�r�r�r)rrrorovs>���O��K�� � �4�!�4�C�
!�+�

.�
.rroc��eZdZeZdZy)�TestRedirectStdout�stdoutN)rrr�redirect_stdoutrqrur)rrr�r�����%�O��Krr�c��eZdZeZdZy)�TestRedirectStderr�stderrN)rrr�redirect_stderrrqrur)rrr�r��r�rr�c�f�eZdZejd��Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zy)�TestSuppressc�p�tj}t�}|j|j|�yr
)�suppressr�rZr�s   rrzTestSuppress.test_instance_docs�s*�� �'�'���j��������l�3rc�n�tt�5}|j|�ddd�y#1swYyxYwr
)r�rr�)rr�s  r�test_no_result_from_enterz&TestSuppress.test_no_result_from_enter�s&��
�j�
!�\����l�+�"�
!�
!�s�+�4c��tt�5|jtdd�d�ddd�y#1swYyxYw)Nrwr�� )r�rrZ�powr3s r�test_no_exceptionzTestSuppress.test_no_exception�s,��
�j�
!����S��A�Y��+�"�
!�
!�s�6�?c�b�tt�5td�ddd�y#1swYyxYw)Nr�)r�r-rur3s r�test_exact_exceptionz!TestSuppress.test_exact_exception�s��
�i�
 ���F�!�
 �
 �s�%�.c�V�tt�5ddddd�y#1swYyxYw)Nr��2)r��LookupErrorr3s r�test_exception_hierarchyz%TestSuppress.test_exception_hierarchy�s��
�k�
"��B�K�#�
"�
"�s��(c��|jt�5tt�5ddzddd�ddd�y#1swY�xYw#1swYyxYwr0)r,r`r�r-r3s r�test_other_exceptionz!TestSuppress.test_other_exception�s=��
�
�
�0�
1��)�$��!��%�2�
1�$�$��2�
1�s�A	�=�A	�A	�A	�	Ac��|jt�5t�5ddzddd�ddd�y#1swY�xYw#1swYyxYwr0)r,r`r�r3s r�test_no_argszTestSuppress.test_no_args�s9��
�
�
�0�
1����!���2�
1����2�
1�s�A�8�A�A	�A�A
c���ttt�5ddzddd�ttt�5td�ddd�y#1swY�2xYw#1swYyxYw)NrOrr�)r�r`r-rur3s r�test_multiple_exception_argsz)TestSuppress.test_multiple_exception_args�sC��
�'��
3�
�a�C�4�
�'��
3���F�4�
3�4�
3��
3�
3�s�A�A�A�A!c�8�tt�}|5	ddd�|5td�ddd�|5|5td�ddd�d}ddzddd�|j�y#1swY�YxYw#1swY�OxYw#1swY�BxYw#1swY�?xYw)Nr�TrOr)r�r�rurF)r�ignore_exceptions�outer_continueds   rr�z!TestSuppress.test_cm_is_reentrant�sz��$�Y�/��
���
���F��
�"��A��#�"�O�
�a�C�	�
	
����(��
��
�
��#�"���
�s8�A,�A8�B�B�B�,A5�8B�B
	�	B�Bc
�z�d�}d�}tt�5|��#1swYnxYwttt�5|��#1swYnxYw|jt�5}tt�5|��#1swYnxYw	ddd�n#1swYnxYw|jjt	dtd�td�g��tt�5tdt�g��#1swYnxYw|jt�5}tt�5tdtd�td�g��#1swYnxYw	ddd�n#1swYnxYw|j|jtdtd�g��|jt�5}tt�5tdtd�td�g��#1swYnxYw	ddd�n#1swYnxYw|j|jt	dtd�g��y)	Nc�V�tdtd�td�td�g�S)NzEG with ValueErrors only�ve1�ve2�ve3)�ExceptionGrouprr)rrr�z4TestSuppress.test_exception_groups.<locals>.<lambda>�s%���&�
��
�
�5� 1�:�e�3D�E�
rc	�j�tdtd�td�td�td�g�S)N� EG with many types of exceptionsr��ke1r��ke2)r�rr"r)rrr�z4TestSuppress.test_exception_groups.<locals>.<lambda>�s*���.�
��
�����E�1B�H�U�O�T�
rr�r�r��message�gr�)	r�rr"r,r��assertExceptionIsLikerg�
GeneratorExit�BaseExceptionGroup)r�eg_ve�eg_all�eg1s    r�test_exception_groupsz"TestSuppress.test_exception_groups�s���
��
���j�
!��'�M�"�
!��
�j�(�
+��(�N�,�
+��
�
�
�~�
.�#��*�%��h��&�%��%�/�
.�
.��	
�"�"��M�M��2��%��(�5�/�2�
�	
��m�
$�$�Y���0A�B�B�%�
$���
�
�1�
2�c��(�#�(��]�3�5G��RU��4W�X�X�$�#��#�3�
2�
2��	
�"�"��M�M�-�i�-��:L�9M�N�	
��
�
�~�
.�#��-�(�(��]�3�5G��RU��4W�X�X�)�(��(�/�
.�
.��	
�"�"��M�M�>�)�h�s�m�_�E�	
sy��'�A�A�'B�7A?�?B	�B�B�*D�D	�!E(�1!E�E	�E(�(E1�9H�	!G*�*G3	�/H�H	N)rrrrr�rr�r�r�r�r�r�r�r�r�r)rrr�r��sG��� � �4�!�4�,�,����
�
�)�(
rr�c�$�eZdZd�Zd�Zd�Zd�Zy)�	TestChdirc��tjjtjjtjj	t
��g|���Sr
)�os�path�join�dirname�realpath�__file__)r�partss  r�make_relative_pathzTestChdir.make_relative_paths>���w�w�|�|��G�G�O�O�B�G�G�,�,�X�6�7�
�
�
�	
rc�B�tj�}|jd�}|j||�t	|�5|jtj�|�ddd�|jtj�|�y#1swY�.xYw)N�data)r��getcwdr�r��chdirrZ)r�old_cwdr�s   r�test_simplezTestChdir.test_simple#sm���)�)�+���(�(��0�����G�V�,�
�6�]����R�Y�Y�[�&�1���������g�.��]�s�%B�Bc��tj�}|jd�}|jd�}|j|||f�t	|�t	|�}}|5|jtj�|�|5|jtj�|�|5|jtj�|�ddd�|jtj�|�ddd�|jtj�|�ddd�|jtj�|�y#1swY��xYw#1swY�fxYw#1swY�FxYw)Nr��ziptestdata)r�r�r��assertNotInr�rZ)rr��target1�target2�chdir1�chdir2s      r�test_reentrantzTestChdir.test_reentrant,s���)�)�+���)�)�&�1���)�)�-�8������7�G�"4�5��w���w����
����R�Y�Y�[�'�2��� � �����g�6���$�$�R�Y�Y�[�'�:��� � �����g�6�	�

���R�Y�Y�[�'�2��	
�������g�.�	�V������V�s<�#'E3�
'E'�1%E�,E'�,E3�E$� E'�'E0	�,E3�3E<c��tj�}|jd�}|j||�	t	|�5|jtj�|�t
d��#1swYnxYwn1#t$r%}|jt|�d�Yd}~nd}~wwxYw|jtj�|�y)Nr��boom)r�r�r�r�r�rZrx�str)rr�r��res    r�test_exceptionzTestChdir.test_exception=s����)�)�+���(�(��0�����G�V�,�	.��v��� � �����f�5�"�6�*�*�������	.����S��W�f�-�-��	.���������g�.s)�B�0A4�4A=�9B�	B/�
B*�*B/N)rrrr�r�r�r�r)rrr�r�s��
�/�/�"/rr��__main__)#r�r{r�rtr$r5r8�unittest�
contextlibrjr�test.supportr�test.support.testcaserr��TestCaserrKr�rrr.r�rQrZr�rlror�r�r�r�r�mainr)rr�<module>r�s^��?�	�	�
�������"�6��(E��!2�!2�(E�VF#�X�.�.�F#�R
%�h�'�'�%�D#�(�+�+�#�"�(�+�+�"�$-'�(�+�+�-'�`� ��]<�8�,�,�]<�@J6�J6�Z�%�x�'8�'8��6.�6.�r�+�X�->�->���+�X�->�->��^
�'��):�):�^
�B,/��!�!�,/�^�z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists