HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_logging.cpython-312.opt-2.pyc
�

~h�e^���	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlmZmZddlmZddlmZddlmZddlmZddlmZddlm Z dd	lm!Z!dd
lm"Z"ddl#m$Z$ddl%Z%ddl&Z&ddl'Z'ddl(Z(ddl)Z)ddl*Z*ddl+Z+ddl,m-Z-m.Z.dd
l/m0Z0m1Z1ddl2m3Z3m4Z4m5Z5m6Z6	ddl7Z7ddl8Z8ddl9Z9	ddl;Z;e)jxejzd�Z>Gd�de)j~�Z@Gd�de@�ZAGd�de@�ZBdZCdZDdZEdZFdZGdZHdZIdZJdZKdZLeMeLeCd z�ZNeCd!eDd"eEd#eFd$eGd%eHd&eId'eJd(eKd)eLd*i
ZOGd+�d,ej��ZQGd-�d.ej��ZRGd/�d0e@�ZSd1�ZTGd2�d3e@�ZUGd4�d5eV�ZWGd6�d7ej��ZYGd8�d9eV�ZZGd:�d;e@�Z[Gd<�d=e"j��Z]Gd>�d?eV�Z^Gd@�dAe^e-�Z_GdB�dCe^e5�Z`GdD�dEe^e3�ZaebedF�rGdG�dHe`�ZcGdI�dJea�Zdej��ej��GdK�dLe@���ZgGdM�dNe@�ZhGdO�dPej��ZjdQ�ZkGdR�dSe@�Zlej��ej��GdT�dUe@���Zme)j�ebedF�dV�GdW�dXem��Zoej��ej��GdY�dZe@���Zpe)j�ebedF�dV�Gd[�d\ep��Zqej��ej��Gd]�d^e@���Zre)j�ebedF�dV�Gd_�d`er��Zse)j�ej�da�Gdb�dcer��Zuej��ej��Gdd�dee@���ZvGdf�dge@�ZwGdh�die@�ZxGdj�dke@�Zyd�dl�ZzGdm�dn�Z{do�Z|Gdp�dqej��Z}Gdr�dsej�j��Z�Gdt�due�j�Z�dv�Z�d�dw�Z�Gdx�dye@�Z�Gdz�d{e@�Z�Gd|�d}e@�Z�Gd~�de�j�Z�Gd��d�e@�Z�ej��Gd��d�e@��Z�ebej�d��r)ddl�Z�dd�l�m�Z�ej��Gd��d�e@��Z�e�j d�Z�Gd��d�e�j$�Z�e��Z�Gd��d��Z�Gd��d�e)j~e��Z�Gd��d�e�j.�Z�Gd��d�e)j~�Z�Gd��d�e@�Z�Gd��d�e@�Z�Gd��d��Z�Gd��d�e�j:�Z�Gd��d�e@�Z�Gd��d�e@�Z�Gd��d�e@�Z�Gd��d�e)j~�Z�Gd��d�e)j~�Z�Gd��d�e@e��Z�Gd��d�e@�Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�d��Z�d�d�d�d�d�d�e�d�d����ffD]\Z�Z�e�e�fd��Z�e�e�d�e�ze���e)j�e7d��Gd��d�e@��Z�Gd��d�e)j~�Z�d��Z�e�d�k(re)�jd�yy#e:$r
dxZ7xZ8Z9Y��wxYw#e:$rY��wxYw)��N)�assert_python_ok�assert_python_failure)�support)�
import_helper)�	os_helper)�
socket_helper)�threading_helper)�warnings_helper)�asyncore)�smtpd)�TestHandler)�
HTTPServer�BaseHTTPRequestHandler)�urlparse�parse_qs)�ThreadingUDPServer�DatagramRequestHandler�ThreadingTCPServer�StreamRequestHandlerz?libasan has a pthread_create() dead lock related to thread+forkc�4�eZdZ	dZdZdZd�Zd�Zd	d�Zd�Z	y)
�BaseTestz&%(name)s -> %(levelname)s: %(message)sz^([\w.]+) -> (\w+): (\d+)$rc��	tj�|_tj�j
j}tj�	tjj�|_
tjdd|_|j�x|_
}tjj�|_tj j�|_ix|_}|D]}t'||dd�||<�	tj(�tjd�|_tjd�|_tjd�|_|j.j1�|_t5j6�|_|j.j;tj<�tj>|j8�|_ tjB|jD�|_#|j@jI|jF�|j*jK�r;|j*jL|j.jLz}tOd|z��|j,jK�r;|j,jL|j.jLz}tOd|z��|j.jQ|j@�|jS|j*jK��|jS|j,jK��y#tj(�wxYw)N�disabledu«×»uĿÖG�zUnexpected handlers: %s)*r	�threading_setup�_threading_key�logging�	getLogger�manager�
loggerDict�_acquireLock�	_handlers�copy�saved_handlers�_handlerList�saved_handler_list�
saved_loggers�_nameToLevel�saved_name_to_level�_levelToName�saved_level_to_name�
logger_states�getattr�_releaseLock�logger1�logger2�root_logger�getEffectiveLevel�original_logging_level�io�StringIO�stream�setLevel�DEBUG�
StreamHandler�	root_hdlr�	Formatter�
log_format�root_formatter�setFormatter�hasHandlers�handlers�AssertionError�
addHandler�
assertTrue)�self�logger_dictr'r,�name�hlists      �8/opt/alt/python312/lib64/python3.12/test/test_logging.py�setUpzBaseTest.setUp]s���	9�.�>�>�@����'�'�)�1�1�<�<������	#�")�"3�"3�"8�"8�":�D��&-�&:�&:�1�&=�D�#�1<�1A�1A�1C�C�D���'.�';�';�'@�'@�'B�D�$�'.�';�';�'@�'@�'B�D�$�13�3�D���%�
@��&-�m�D�.A�.8�$�'@�
�d�#�
@�
� � �"��(�(��8����(�(�)=�>���"�,�,�R�0���&*�&6�&6�&H�&H�&J��#��k�k�m������!�!�'�-�-�0� �.�.�t�{�{�;���%�/�/����@������#�#�D�$7�$7�8��<�<�#�#�%��L�L�)�)�D�,<�,<�,E�,E�E�E� �!:�U�!B�C�C��<�<�#�#�%��L�L�)�)�D�,<�,<�,E�,E�E�E� �!:�U�!B�C�C����#�#�D�N�N�3�������0�0�2�3�������0�0�2�3��-
� � �"�s
�B;M&�&M<c��	|jj�|jj|j�|jj
r[|jj
d}|jj|�|j�|jj
r�[|jj
|j�tj�	tjj�tjj|j�tjj�tjj|j�tj j�tj j|j"�|j$tj&ddtj(�j*}d|_|j.}|j�|j|j0�|j2}|j2D]}||��	|||j0|_�!	tj6�|j9�t;j<|j>�y#tj6�wxYw)Nr) r6�closer1�
removeHandlerr:r@r7r3rr!r*�clear�updater+r(r)r"r$r&r%rr�disabler r'r,rr.�
doCleanupsr	�threading_cleanupr)rD�hrr r,rFs      rH�tearDownzBaseTest.tearDown�s��	����������&�&�t�~�~�6����'�'�� � �)�)�!�,�A����*�*�1�-�
�G�G�I����'�'�	
���!�!�$�"=�"=�>�����	#�� � �&�&�(�� � �'�'��(@�(@�A�� � �&�&�(�� � �'�'��(@�(@�A����#�#�%����$�$�T�%8�%8�9�&*�&=�&=�G� � ��#��'�'�)�1�1�G��G�O� �+�+�J��������d�0�0�1� �.�.�M��*�*�
L�� ��&�2�8E�d�8K�D�&�&�t�,�5�
L�
� � �"������*�*�D�,?�,?�@��
� � �"�s�,E.J6�J6�6KNc��	|xs|j}tj|xs|j�}|j	�j�}|j
t|�t|��t||�D]U\}}|j|�}|s|jd|z�|j
t|j��|��W|j�}|r|jd|z�yy)Nz*Log line does not match expected pattern:
z'Remaining output at end of log stream:
)r6�re�compile�expected_log_pat�getvalue�
splitlines�assertEqual�len�zip�search�fail�tuple�groups�read)	rD�expected_valuesr6�pat�actual_lines�actual�expected�match�ss	         rH�assert_log_lineszBaseTest.assert_log_lines�s���	/��&�4�;�;���j�j��5�� 5� 5�6�����(�3�3�5������\�*�C��,@�A� #�L�/� B�	>��F�H��J�J�v�&�E���	�	�G�"�#�$����U�5�<�<�>�2�H�=�	>�
�K�K�M����I�I�@�1�D�E�
�c�L�	|xjdz
c_d|jzS)N�z%d)�message_num�rDs rH�next_messagezBaseTest.next_message�s)��	����A����d�&�&�&�&rj�NN)
�__name__�
__module__�__qualname__r<rWrmrIrSriro�rjrHrrUs-��'�9�J�4���K�(4�T A�DF�$'rjrc�8�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�BuiltinLevelsTestc��|j}tjd�}|jtj�tj
tjd�i�}|jtj�tjd�}|jtj�|jtj|��|j|��|jtj|��|j|��|j|��|j|��|jtj|��|j|��|j|��|j|��|j|��|j|��|j|��|j|��|j|��|jgd��y)N�ERR�INF�DEB))rx�CRITICAL�1)rx�ERROR�2)ryr{�3)ryr}�4)ry�WARNING�5)ry�INFO�6)rzr{�7)rzr}�8)rzr��9)rzr��10)rzr8�11)rorrr7r}�
LoggerAdapterr�r8�logr{�error�warning�info�debugri)rD�mrxryrzs     rH�	test_flatzBuiltinLevelsTest.test_flat�sr����������&�����W�]�]�#��#�#�G�$5�$5�e�$<�b�A�����W�\�\�"�����&�����W�]�]�#�	���� � �!�#�&��	�	�!�#������ � �!�#�&��	�	�!�#�����A�C�������
����� � �!�#�&��	�	�!�#�����A�C�������
��	�	�!�#��	���A�C�������
��	�	�!�#���	�	�!�#�����
�	rjc��|j}tjd�}|jtj�tjd�}|jtj
�|j
tj|��|j|��|j|��|j|��|j|��|jddg�y)Nry�INF.ERR)r�r{r|)r�r}r~�
rorrr7r�r}r�r{r�r�r�r�ri)rDr�ry�INF_ERRs    rH�test_nested_explicitz&BuiltinLevelsTest.test_nested_explicit�s�����������&�����W�\�\�"��$�$�Y�/��������'�	���G�$�$�a�c�*��
�
�a�c��	���������Q�S���
�
�a�c�����(�%�
�	rjc��|j}tjd�}|jtj�tjd�}|jtj
�tjd�}tjd�}tjd�}|j
tj|��|j|��|j|��|j|��|j
tj|��|j|��|j|��|j|��|j|��|j|��|jgd��y)Nryr��	INF.UNDEF�
INF.ERR.UNDEF�UNDEF))r�r{r|)r�r}r~)r�r�r)r�r�r�)r�r{r�)r�r}r�r�)rDr�ryr��	INF_UNDEF�
INF_ERR_UNDEFr�s       rH�test_nested_inheritedz'BuiltinLevelsTest.test_nested_inheriteds>����������&�����W�\�\�"��$�$�Y�/��������'��%�%�k�2�	��)�)�/�:�
��!�!�'�*��	�
�
�g�&�&���,����������!�#�����q�s�����'�*�*�A�C�0����A�C� �	���������a�c�"����1�3�����A�C� ����
�	rjc�B�|j}tjd�}tjd�}tjd�}|jtj�|jtj|��|j|��|jtj|��|j|��|j|��|j|��|jgd��y)Nry�INF.BADPARENT.UNDEF�
INF.BADPARENT))r�r{r|)r�r�r~)r�r{r)r�r�r�)
rorrr7r�r��FATALr�r�ri)rDr�ry�
GRANDCHILD�CHILDs     rH�test_nested_with_virtual_parentz1BuiltinLevelsTest.test_nested_with_virtual_parent.s�����������&���&�&�'<�=�
��!�!�/�2�����W�\�\�"�	���w�}�}�a�c�*�������
�	�	�'�-�-���%�
�
�
�1�3��	������
���A�C�����
�	rjc���	|jtjd�tj�|jtjtj�d�y)Nr�)rZr�getLevelNamer�rns rH�test_regression_22386z'BuiltinLevelsTest.test_regression_22386HsC��4�����-�-�f�5�w�|�|�D�����-�-�g�l�l�;�V�Drjc�n�tjd�}|j|tj�y)Nr�)rr�rZr�)rD�fatals  rH�test_issue27935z!BuiltinLevelsTest.test_issue27935Ms&���$�$�W�-�������
�
�.rjc���	tjtjd�|jtjtjd�|j	tj
tj�d�|j	tj
tj�d�|j	tj
d�tj�y)Nrr��NOTSET)r�addLevelNamer��
addCleanuprZr�r�rns rH�test_regression_29220z'BuiltinLevelsTest.test_regression_29220Qs���4����W�\�\�2�.�����,�,�g�l�l�F�C�����-�-�g�l�l�;�R�@�����-�-�g�n�n�=�x�H�����-�-�h�7����HrjN)
rqrrrsr�r�r�r�r�r�r�rtrjrHrvrv�s,��4�-�^�.!�F�4E�
/�Irjrvc� �eZdZ	d�Zd�Zd�Zy)�BasicFilterTestc��tjd�}|jjd}	|j	|�tj
d�}tj
d�}tj
d�}tj
d�}|j
|j��|j
|j��|j
|j��|j
|j��|jddg�|j|�y#|j|�wxYw)N�	spam.eggsr�spam�spam.eggs.fish�spam.bakedbeans�r�r�r~�r�r�r)
r�Filterr1r@�	addFilterrr�rori�removeFilter)rD�filter_�handlerr��	spam_eggs�spam_eggs_fish�spam_bakedbeanss       rH�test_filterzBasicFilterTest.test_filter]s
���.�.��-���"�"�+�+�A�.��	*����g�&��$�$�V�,�D��)�)�+�6�I�$�.�.�/?�@�N�%�/�/�0A�B�O��I�I�d�'�'�)�*��N�N�4�,�,�.�/����� 1� 1� 3�4�� � ��!2�!2�!4�5��!�!�*�/�#�
�

� � ��)��G� � ��)�s�C4D6�6E	c�t�d�}|jjd}	|j|�tjd�}tjd�}tjd�}tjd�}|j|j
��|j|j
��|j|j
��|j|j
��|jddg�|j|�y#|j|�wxYw)	Nc�j�|jjd�}dj|dd�}|dk(S)N�.�r�)rF�split�join)�record�parts�prefixs   rH�
filterfuncz8BasicFilterTest.test_callable_filter.<locals>.filterfuncys5���K�K�%�%�c�*�E��X�X�e�B�Q�i�(�F��[�(�(rjrr�r�r�r�r�r�)	r1r@r�rrr�rorir�)rDr�r�r�r�r�r�s       rH�test_callable_filterz$BasicFilterTest.test_callable_filterus��	)�
�"�"�+�+�A�.��	-����j�)��$�$�V�,�D��)�)�+�6�I�$�.�.�/?�@�N�%�/�/�0A�B�O��I�I�d�'�'�)�*��N�N�4�,�,�.�/����� 1� 1� 3�4�� � ��!2�!2�!4�5��!�!�*�/�#�
�

� � ��,��G� � ��,�s�C4D$�$D7c��tj�}tjddi�}|j|j	|��y)NrFr�)rr��
makeLogRecordrC�filter)rD�f�rs   rH�test_empty_filterz!BasicFilterTest.test_empty_filter�s7���N�N����!�!�6�;�"7�8����������$rjN)rqrrrsr�r�r�rtrjrHr�r�Ys��(�*�0-�:%rjr��x�w�v�u�t�s�r�q�p�orl�Silent�Taciturn�Terse�Effusive�Sociable�Verbose�	Talkative�	Garrulous�
Chatterbox�Boringc��eZdZ	d�Zy)�GarrulousFilterc�(�|jtk7S�N)�levelno�	GARRULOUS�rDr�s  rHr�zGarrulousFilter.filter�s���~�~��*�*rjN�rqrrrsr�rtrjrHr�r��s
��3�+rjr�c��eZdZ	d�Zy)�VerySpecificFilterc�2�|jttfvSr�)r��SOCIABLE�TACITURNr�s  rHr�zVerySpecificFilter.filter�s���~�~�h��%9�9�9rjNr�rtrjrHr�r��s
��?�:rjr�c�<�eZdZ	dZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�CustomLevelsAndFiltersTest�^[\w.]+ -> (\w+): (\d+)$c��tj|�tj�D]\}}t	j
||��yr�)rrI�my_logging_levels�itemsrr�)rD�k�vs   rHrIz CustomLevelsAndFiltersTest.setUp�s:�����t��%�+�+�-�	'�D�A�q�� � ��A�&�	'rjc�Z�tD]"}|j||j���$yr�)�LEVEL_RANGEr�ro)rD�logger�lvls   rH�log_at_all_levelsz,CustomLevelsAndFiltersTest.log_at_all_levels�s(���	1�C��J�J�s�D�-�-�/�0�	1rjc�l�dtjfd�}tjd�}tjd�}tj�}tj�}tj
|�}tj
|�}|j
|�|j|�|j|�|jd�|j�|j�|j|j�d�|j|j�d�y)Nr�c�>�tj|�}d|_|S)Nznew message!)r#�msg)r�s rH�replace_messagezWCustomLevelsAndFiltersTest.test_handler_filter_replaces_record.<locals>.replace_message�s���Y�Y�v�&�F�'�F�J��Mrj�parentzparent.childzoriginal messagezoriginal message
z
new message!
)r�	LogRecordrr4r5r9r�rBr��flushrZrX)rDrr�child�stream_1�stream_2�	handler_1�	handler_2s        rH�#test_handler_filter_replaces_recordz>CustomLevelsAndFiltersTest.test_handler_filter_replaces_record�s���	�G�$5�$5�	��"�"�8�,���!�!�.�1���;�;�=���;�;�=���)�)�(�3�	��)�)�(�3�	����O�,����)�$�
����#�
�
�
�%�&�������������*�*�,�.B�C�����*�*�,�.>�?rjc�h��t��G�fd�dtj�}tjd�}|j	tj
�|j
|��|j
|��|jd�|jdt���y)Nc�2��eZdZdejf�fd�Zy)�WCustomLevelsAndFiltersTest.test_logging_filter_replaces_record.<locals>.RecordingFilterr�c�b���jt|��tj|�Sr�)�add�idr#)rDr��recordss  �rHr�z^CustomLevelsAndFiltersTest.test_logging_filter_replaces_record.<locals>.RecordingFilter.filter�s"������B�v�J�'��y�y��(�(rjN)rqrrrsrrr�)rs�rH�RecordingFilterr�s���
)�W�%6�%6�
)rjrr�rr�)
�setrr�rr7r�r�r�rZr[)rDrr�rs   @rH�#test_logging_filter_replaces_recordz>CustomLevelsAndFiltersTest.test_logging_filter_replaces_record�s~����%��	)�g�n�n�	)�
�"�"�8�,��������%�����*�+�����*�+����E������C��L�)rjc��|jjt�|j|j�|j	gd��y)N)�r�r��r�r��r�r��r�r��r�r��r�r�)r1r7�VERBOSErrirns rH�test_logger_filterz-CustomLevelsAndFiltersTest.test_logger_filter	s=�����!�!�'�*����t�/�/�0����
�	rjc��|jjdjt�	|j	|j�|jgd��|jjdjtj�y#|jjdjtj�wxYw)Nr)rrrrr)r1r@r7r�rrirr�rns rH�test_handler_filterz.CustomLevelsAndFiltersTest.test_handler_filters������!�!�!�$�-�-�h�7�	B��"�"�4�#3�#3�4��!�!�#�
�
���%�%�a�(�1�1�'�.�.�A��D���%�%�a�(�1�1�'�.�.�A�s�.B�8Cc�@�|jjd}d}t�}|j|�	|j	|j�gd�}|j|�t
�}|jj|�|j	|j�|j|gd�z�|r|jj|�|j|�y#|r|jj|�|j|�wxYw)Nr)	)r�r|)r�r~)r�r�rrrrrr))r�r�)r��12)r��14)r��15)r��17)r��18)r��20)r1r@r�r�rrir�r�)rDr��specific_filter�garr�first_liness     rH�test_specific_filtersz0CustomLevelsAndFiltersTest.test_specific_filters's����"�"�+�+�A�.����� �����$��!	'��"�"�4�#3�#3�4��K�
�!�!�+�.�0�2�O����&�&��7��"�"�4�#3�#3�4��!�!�+�
1
�
#
�

��� � �-�-�o�>�� � ��&���� � �-�-�o�>�� � ��&�s�BC-�-0DN)rqrrrsrWrIrr
rr r"r-rtrjrHr�r��s2��J�3��'�
1�@�8*�"�B� ('rjr�c�`�tj|i|��\}}tj|�|Sr�)�tempfile�mkstemp�osrK)�args�kwargs�fd�fns    rH�make_temp_filer6Rs+��
�
�
�t�
.�v�
.�F�B���H�H�R�L�
�Irjc�\�eZdZd�Zd�Zd�Zejejdk(d�eje
jd�ej�e
jd�d�����Ze
j �ej�ed	����Zy
)�HandlerTestc��tj�}d|_|j|jd�d|_|j|jd�|j	t
|jd�y)N�generic�anothergeneric)r�HandlerrFrZ�assertRaises�NotImplementedError�emit�rDrRs  rH�	test_namezHandlerTest.test_nameYs\���O�O�������������+�!���������!1�2����-�q�v�v�t�<rjc���tjdv�rdD�]�}t�}|stj|�t
jj|dd��}|r�|j|j}}|j|d�|j|d�tjddi�}|j|�tj|�|jtjj|��|j|�|j!tjj|��n8|j|jd�|j|jd�|j#�|s��|tj|����tjd	k(rd
}nd}	t
jj%|�}|j|j&|j(�|j!|j*�|j#�dD]j}|d
k(r2|j/t0t
jj2dd|��:t
jj3dd|�}|j#��lt
jj5d�}tji�}|j!|j7|��|j#�t
jj5d�}|j|j7|��|j#�y#t,$rY��/wxYw)N��linux�darwin)TF�utf-8T��encoding�delay���r�TestrEz/var/run/syslogz/dev/log)�GET�POST�PUTrN�	localhostz/logrrl)�sys�platformr6r1�unlinkrr@�WatchedFileHandler�dev�inorZr��handle�assertFalse�path�existsrCrK�
SysLogHandler�facility�LOG_USER�
unixsocket�OSErrorr=�
ValueError�HTTPHandler�BufferingHandler�shouldFlush)	rD�existingr5rRrTrUr��sockname�methods	         rH�test_builtin_handlersz!HandlerTest.test_builtin_handlersas����<�<�.�.�)�
"��#�%����I�I�b�M��$�$�7�7��W�TX�7�Y��� �u�u�a�e�e��C��$�$�S�"�-��$�$�S�"�-��-�-�u�f�o�>�A��H�H�Q�K��I�I�b�M��$�$�R�W�W�^�^�B�%7�8��H�H�Q�K��O�O�B�G�G�N�N�2�$6�7��$�$�Q�U�U�B�/��$�$�Q�U�U�B�/����	���I�I�b�M�-
"�.�|�|�x�'�,��%��
��$�$�2�2�8�<��� � ����Q�Z�Z�8�������-����	�-�	�F�����!�!�*�g�.>�.>�.J�.J�"-�v�v�?��$�$�0�0��f�f�M�����	�
	�
���-�-�a�0���!�!�"�%������
�
�a�(�)�	���	����-�-�a�0��������q�)�*�	���	���
��
�s�A0M�	M#�"M#c�>�	t�}tj|�tj|�}t
j|dfft
jj|dfft
jj|dfff}tjdvr"|t
jj|dfffz
}|D]`\}}||ddi�}|jtjj|��|j!�tj|��by)N�w�arRrCrHrF)r6r1rR�pathlib�Pathr�FileHandlerr@�RotatingFileHandler�TimedRotatingFileHandlerrPrQrSrCrXrYrK)rDr5�pfn�cases�clsr2rRs       rH�test_path_objectszHandlerTest.test_path_objects�s���	�
�
��
�	�	�"�
��l�l�2����(�(�3��*�5��%�%�9�9�C��:�F��%�%�>�>��c�
�K���
�<�<�.�.��w�'�'�:�:�S�#�J�G�I�I�E��	�I�C���T�,�G�,�A��O�O�B�G�G�N�N�2�.�/�
�G�G�I��I�I�b�M�		rj�ntz/WatchedFileHandler not appropriate for Windows.z'Emscripten cannot fstat unlinked files.�walltimec	�����fd�}d}d}d�_d�_dD�]F}tdd�}tj|||f��}d|_|j
�tjj|d|�	�}tjd
�}|j|�	t|�D]Y}	tjd�tjdd
i�}
	tj��_|j!|
��[	|j'�|j)�t*j,j/|�s��2t+j0|���Iy#t"$r't%d�j�d�j����wxYw#|j'�|j)�t*j,j/|�rt+j0|�wwxYw)Nc���t|�D]]}	tj|�tj��_tjdtjdd�z��_y#t
$rY�:wxYw)Ng����Mbp?r�)	�ranger1rR�time�
deletion_timer^�sleep�random�randint)�fname�tries�_rDs   �rH�remove_loopz*HandlerTest.test_race.<locals>.remove_loop�sg����5�\�
9����I�I�e�$�)-����D�&��
�
�5�6�>�>�!�Q�#7�7�8�

9������s�.A.�.	A:�9A:i��FT�.logztest_logging-3-��targetr2TrFrGz'%(asctime)s: %(levelname)s: %(message)s�{�G�zt?r�testingzDeleted at z, opened at )�handle_timerzr6�	threading�Thread�daemon�startrr@rSr;r>rxryr{r�rV�	Exception�printr�rKr1rXrYrR)rDr��	del_count�	log_countrIr5�removerrRr�r�r�s`          rH�	test_racezHandlerTest.test_race�s����	9��	��	����!���"�	"�E���(9�:�B��&�&�k��Y��P�G�!�G�N��M�M�O�� � �3�3�B��PU�3�V�A��!�!�"K�L�A�
�N�N�1��
"��y�)�
�A��J�J�u�%��-�-�u�i�.A�B�A��+/�9�9�;��(������
��������	��7�7�>�>�"�%��I�I�b�M�1	"��%���04�0B�0B�04�0@�0@�B�C��	���������	��7�7�>�>�"�%��I�I�b�M�&�s%�$:F�*E&�	F�&0F�F�AG0c�J����	Gd�dtj�}|jttj�d�|��|j�jjj�d�_	|jttj�d�|jttj�d�tjd�}|j��|jtj�t!j"��t!j"�����fd�}t!j$|d�	�}|j'��j)�t+j,�}|dk(r(	|j/d
�t+j0d�y|j/d��j3�|j5�t7j8|d��y#t+j0d�wxYw)
Nc�$��eZdZ�fd�Zd�Z�xZS)�AHandlerTest.test_post_fork_child_no_deadlock.<locals>._OurHandlerc�p��t�|��tjt	ddd����|_y)Nz	/dev/null�wtrF�rH�r6)�super�__init__rr9�open�sub_handler�rD�	__class__s �rHr�zJHandlerTest.test_post_fork_child_no_deadlock.<locals>._OurHandler.__init__�s.����� �"�#*�#8�#8���T�G�D�$F�� rjc���|jj�	|jj|�|jj�y#|jj�wxYwr�)r��acquirer?�releaser�s  rHr?zFHandlerTest.test_post_fork_child_no_deadlock.<locals>._OurHandler.emit�sR��� � �(�(�*�/��$�$�)�)�&�1��$�$�,�,�.��D�$�$�,�,�.�s�A�A.�rqrrrsr�r?�
__classcell__�r�s@rH�_OurHandlerr��s���
F�

/rjr�rz*because we need at least one for this testrl� test_post_fork_child_no_deadlockc�:��tj�	�j�	�j��j	d��j�	tj�y#�j�wxYw#tj�wxYw)N��?)rr!r�r�waitr�r.)�+fork_happened__release_locks_and_end_thread�locks_held__ready_to_fork�refed_hs���rH�lock_holder_thread_fnzKHandlerTest.test_post_fork_child_no_deadlock.<locals>.lock_holder_thread_fnsq���� � �"�
'����!�&�-�1�1�3�@�D�D�S�I��O�O�%��$�$�&���O�O�%���$�$�&�s"�B�!A/�	B�/B�B�Bz,test_post_fork_child_no_deadlock lock holder)r�rFz#Child process did not deadlock. \o/z&Parent process returned from fork. \o/)�exitcode)rr<rZr[r"r�r�r6rKrF�
assertGreater�_at_fork_reinit_lock_weaksetrrBr7r8r��Eventr�r�r�r1�forkr��_exitrr�r�wait_process)	rDr��test_loggerr��lock_holder_thread�pidr�r�r�s	      @@@rHr�z,HandlerTest.test_post_fork_child_no_deadlock�s����	M�	/�'�/�/�	/�	
����W�.�.�/��3��-������+�+�2�2�8�8�9�C������3�w�0�0�1�1�5����3�w�C�C�D�a�H��'�'�(J�K�����w�'����W�]�]�+�$-�O�O�$5�!�6?�o�o�6G�3�	'�2'�-�-�,�C�E��	� � �"�!�&�&�(��g�g�i���!�8�
�� � �!G�H������
���F�G�7�;�;�=��#�#�%�� � ��q�1�������s�H�H"N)rqrrrsrArfrr�unittest�skipIfr1rFr�
is_emscriptenr	�requires_working_threading�requires_resourcer��
requires_fork�skip_if_asan_forkr�rtrjrHr8r8Xs���=�3�j�,�X�_�_�R�W�W��_�&W�X��X�_�_����H��1��0�0�2��W���z�*�)"�+�3��Y�)"�^�W����0��0�0�2��H2��3��H2rjr8c��eZdZd�Zy)�	BadStreamc��td��)N�deliberate mistake)�RuntimeError)rD�datas  rH�writezBadStream.write0s���/�0�0rjN)rqrrrsr�rtrjrHr�r�/s��1rjr�c��eZdZd�Zy)�TestStreamHandlerc��||_yr�)�error_recordr�s  rH�handleErrorzTestStreamHandler.handleError4s
��"��rjN)rqrrrsr�rtrjrHr�r�3s��#rjr�c�(�eZdZejZdZy)�StreamWithIntNamer�N)rqrrrsrr��levelrFrtrjrHr�r�7s���N�N�E��Drjr�c��eZdZd�Zd�Zd�Zy)�StreamHandlerTestc���tt��}tji�}tj}	|j|�|j
|j|�tjt��}tj�5}|j|�d}|j||j��ddd�dt_tj�5}|j|�|jd|j��ddd�|t_y#1swY�nxYw#1swY�!xYw#|t_wxYw)Nz"
RuntimeError: deliberate mistake
Fr)r�r�rr��raiseExceptionsrV�assertIsr�r9r�captured_stderr�assertInrXrZ)rDrRr��	old_raise�stderrrs      rH�test_error_handlingz%StreamHandlerTest.test_error_handling<s	���i�k�*���!�!�"�%���+�+�	�	0�
�H�H�Q�K��M�M�!�.�.�!�,��%�%�i�k�2�A��(�(�*�
6�f������<���
�
�c�6�?�?�#4�5�
6�
',�G�#��(�(�*�
8�f������� � ��V�_�_�%6�7�
8�'0�G�#�
6�
6��
8�
8��'0�G�#�s<�AE�4D9�'E�32E�%E�9E�>E�E�
E�
Ec�B�	tj�}tj�}|j	|�}|j|tj�|j	|�}|j||�|j	|�}|j|�yr�)	rr9r4r5�	setStreamr�rPr��assertIsNone)rDrRr6�oldres     rH�test_stream_settingz%StreamHandlerTest.test_stream_settingRsz��	�
�!�!�#��������k�k�&�!���
�
�c�3�:�:�&����S�!���
�
�f�f�%����S�!�����&�!rjc�t�tjt��}|jt	|�d�y)Nz<StreamHandler 2 (NOTSET)>)rr9r�rZ�reprr@s  rH�'test_can_represent_stream_with_int_namez9StreamHandlerTest.test_can_represent_stream_with_int_name`s+���!�!�"3�"5�6������a��">�?rjN)rqrrrsr�r�r�rtrjrHr�r�;s��0�,"�@rjr�c�,�eZdZ	d�Zd�Zd�Zd�Zd�Zy)�TestSMTPServerc���tjj||d|d��|jj	�d|_||_d|_d|_||_	y)NT)�map�decode_datarlF)
r�
SMTPServerr��socket�getsockname�port�_handler�_thread�_quit�
poll_interval)rD�addrr�r��sockmaps     rHr�zTestSMTPServer.__init__|s\��
���!�!�$��d��.2�	"�	4��K�K�+�+�-�a�0��	���
������
�*��rjc�.�	|j||||�yr�)r�)rD�peer�mailfrom�rcpttosr�s     rH�process_messagezTestSMTPServer.process_message�s��	�	
�
�
�d�H�g�t�4rjc��	tj|j|jf��x|_}d|_|j
�y�Nr�T�r�r��
serve_foreverr�r�r�r��rD�ts  rHr�zTestSMTPServer.start��H��	�%�+�+�4�3E�3E�26�2D�2D�1F�H�	H���q����	���	rjc�~�	|js0tj||jd��|js�/yy)Nrl)r��count)r�r�loop�_map)rDr�s  rHr�zTestSMTPServer.serve_forever�s-��	��*�*��M�M�-�T�Y�Y�a�@��*�*rjc���	d|_tj|j�d|_|j	�tj|jd��y)NT)r��
ignore_all)r�r	�join_threadr�rKr�	close_allr�rns rH�stopzTestSMTPServer.stop�sF��	���
��$�$�T�\�\�2�����
�
�����t�y�y�T�:rjN)rqrrrsr�r�r�r�rrtrjrHr�r�gs!���(+�
5��	A�	;rjr�c�2��eZdZ	d�Zd�Z�fd�Zd�Z�xZS)�ControlMixinc�`�d|_||_||_tj�|_yr�)r�r�r�r�r��ready)rDr�r�s   rHr�zControlMixin.__init__�s&�����*�����
��_�_�&��
rjc��	tj|j|jf��x|_}d|_|j
�yr�r�r�s  rHr�zControlMixin.start�r�rjc�b��	|jj�tt|�|�yr�)rrr�rr�)rDr�r�s  �rHr�zControlMixin.serve_forever�s'���	�	
�
�
����
�l�D�/�
�>rjc���	|j�|j�&tj|j�d|_|j	�|j
j
�yr�)�shutdownr�r	r�server_closerrMrns rHrzControlMixin.stop�sQ��	�	
�
�
���<�<�#��(�(����6��D�L������
�
���rj)rqrrrsr�r�r�rr�r�s@rHrr�s����'��?�	rjrc� �eZdZ			dd�Zd�Zy)�TestHTTPServerNc����G��fd�dt��tj||��tj|||�||_y)Nc�2���eZdZdd�Zd�Z���fd�Z�xZS)�=TestHTTPServer.__init__.<locals>.DelegatingHTTPRequestHandlerc�R�|jd�r|jSt|��)N�do_)�
startswith�process_request�AttributeError)rDrF�defaults   rH�__getattr__zITestHTTPServer.__init__.<locals>.DelegatingHTTPRequestHandler.__getattr__�s%���?�?�5�)��/�/�/�$�T�*�*rjc�:�|jj|�yr���serverr�rns rHrzMTestHTTPServer.__init__.<locals>.DelegatingHTTPRequestHandler.process_request�������$�$�T�*rjc�,���rt�|�|g|���yyr�)r��log_message)rD�formatr2�DelegatingHTTPRequestHandlerr�r�s   ���rHrzITestHTTPServer.__init__.<locals>.DelegatingHTTPRequestHandler.log_message�s)�����6��,�,2�;�59�;�rjr�)rqrrrsrrrr�)r�r!r�s@��rHr!r�s���
+�

+�
;�
;rjr!)rrr�r�sslctx)rDr�r�r�r�r"r!s    ` @rHr�zTestHTTPServer.__init__�s>���	;�+A�	;�	���D�$�(D�E����d�G�]�;���rjc��	|jj�\}}|jr|jj|d��}||fS#t$r(}t
jjd|z��d}~wwxYw)NT)�server_sidezGot an error:
%s
)r��acceptr"�wrap_socketr^rPr�r�)rD�sockr��es    rH�get_requestzTestHTTPServer.get_requestsv��	����+�+�-�J�D�$��{�{��{�{�.�.�t��.�F��
�T�z���	�	��J�J���2�Q�6�7���	�s�AA�	A=�#A8�8A=)r�FN)rqrrrsr�r)rtrjrHrr�s��	�58�#'��&	rjrc�0��eZdZ	dZ		dd�Z�fd�Z�xZS)�
TestTCPServerTc��Gd�dt�}tj||||�tj|||�y)Nc��eZdZd�Zy)�;TestTCPServer.__init__.<locals>.DelegatingTCPRequestHandlerc�:�|jj|�yr�rrns rHrVzBTestTCPServer.__init__.<locals>.DelegatingTCPRequestHandler.handle!rrjN)rqrrrsrVrtrjrH�DelegatingTCPRequestHandlerr.s��
+rjr0)rrr�r)rDr�r�r��bind_and_activater0s      rHr�zTestTCPServer.__init__s;��	+�*>�	+�	�#�#�D�$�0K�$5�	7����d�G�]�;rjc�n��tt|��|jj	�d|_y�Nrl)r�r+�server_bindr�r�r�r�s �rHr4zTestTCPServer.server_bind'�)���
�m�T�.�0��K�K�+�+�-�a�0��	rj�r�T)rqrrrs�allow_reuse_addressr�r4r�r�s@rHr+r+s%������47�#'�<�1�1rjr+c�6��eZdZ			dd�Z�fd�Z�fd�Z�xZS)�
TestUDPServerc���G�fd�dt��tj||�|�tj|||�d|_y)Nc�(���eZdZd�Z��fd�Z�xZS)�;TestUDPServer.__init__.<locals>.DelegatingUDPRequestHandlerc�:�|jj|�yr�rrns rHrVzBTestUDPServer.__init__.<locals>.DelegatingUDPRequestHandler.handle@rrjc���|jj�}|r	t�|��yy#t$r|j
js�YywxYwr�)�wfilerXr��finishr^r�_closed)rDr��DelegatingUDPRequestHandlerr�s  ��rHr@zBTestUDPServer.__init__.<locals>.DelegatingUDPRequestHandler.finishCsV����z�z�*�*�,���"��9�4�G�I���#�"�#�{�{�2�2�!� 3�"�s�/� A�A)rqrrrsrVr@r�)r�rBs@�rHrBr<>s���
+�
"�
"rjrBF)rrr�rrA)rDr�r�r�r1rBs     @rHr�zTestUDPServer.__init__<sE���	"�*@�	"�	�#�#�D�$�$?�$5�	7�	���d�G�]�;���rjc�n��tt|��|jj	�d|_yr3)r�r9r4r�r�r�r�s �rHr4zTestUDPServer.server_bindRr5rjc�8��tt|��d|_y)NT)r�r9r
rAr�s �rHr
zTestUDPServer.server_closeVs���
�m�T�/�1���rjr6)rqrrrsr�r4r
r�r�s@rHr9r9+s$���� 58�#'��,1��rjr9�AF_UNIXc�$�eZdZejZy)�TestUnixStreamServerN�rqrrrsr�rE�address_familyrtrjrHrGrG[������rjrGc�$�eZdZejZy)�TestUnixDatagramServerNrHrtrjrHrLrL^rJrjrLc�0�eZdZejZd�Zd�Zy)�SMTPHandlerTestc���i}ttjdf|jd|�}|j	�tj|j
f}tjj|ddd|j��}|j|jdg�g|_t
jddi�}tj�|_|j#|�|j j%|j�|j'�|j)|j j+��|jt-|j�d	�|jd\}}}}	|j|d�|j|dg�|j/d
|	�|j)|	j1d��|j3�y)Nr���MbP?�me�you�Log)�timeoutru	Hello ✓rlz
Subject: Log
u

Hello ✓)r�r�HOSTr�r�r�rr@�SMTPHandler�TIMEOUTrZ�toaddrs�messagesr�r�r��handledrVr�rrC�is_setr[r��endswithrK)
rDr�rr�rRr�r�r�r�r�s
          rH�
test_basiczSMTPHandlerTest.test_basicisu������!3�!3�Q� 7��9M�9M�u� '�)�������"�"�F�K�K�0�����(�(��t�U�E�15���
)�
?��������U�G�,���
��!�!�5�.�"9�:�� ���(���	����������$�,�,�'����
�������+�+�-�.�����T�]�]�+�Q�/�(,�
�
�a�(8�%��h�������4�(�����5�'�*��
�
�(�$�/�����
�
�&8�9�:�	���	rjc�n�|jj|�|jj�yr�)rY�appendrZr)rDr2s  rHr�zSMTPHandlerTest.process_message�s$���
�
���T�"������rjN)rqrrrsr�LONG_TIMEOUTrWr]r�rtrjrHrNrNcs���"�"�G��0rjrNc�^�eZdZ	dZd�Zd�Zd�Zd�Zd�Ze	j�d��Zy)	�MemoryHandlerTestr�c�J�tj|�tjj	dtj
|j�|_tjd�|_	d|j_
|jj|j�y)N�
�memr)rrIrr@�
MemoryHandlerr�r:�mem_hdlrr�
mem_logger�	propagaterBrns rHrIzMemoryHandlerTest.setUp�sj�����t���(�(�6�6�r�7�?�?�7;�~�~�G��
�!�+�+�E�2���$%����!����"�"�4�=�=�1rjc�b�|jj�tj|�yr�)rgrKrrSrns rHrSzMemoryHandlerTest.tearDown�� ���
�
�������$�rjc	�R�|jj|j��|jg�|jj	|j��|jg�|jj|j��gd�}|j|�dD]�}t
d�D]+}|jj|j���-|j|�|jj|j��|t
||dz�D�cgc]}dt|�f��c}z}|j|���|jj|j��|j|�ycc}w)N)�r8r|�r�r~)r�r)rw��	rdr8)rhr�rorir�r�rx�str)rD�lines�n�is    rH�
test_flushzMemoryHandlerTest.test_flush�sX��	
�����d�/�/�1�2����b�!������T�.�.�0�1����b�!������� 1� 1� 3�4�
��
	
���e�$��	)�A��1�X�
;�����%�%�d�&7�&7�&9�:�
;��!�!�%�(�
�O�O�!�!�$�"3�"3�"5�6���a��R��8H�I�1�g�s�1�v�.�I�I�E��!�!�%�(�	)�	
�����d�/�/�1�2����e�$��	Js�=F$c���	|jj|j��|jg�|jj	|j��|jg�|jj|j�|jj�ddg}|j|�tjjdtj|jd�|_|jj|j�|jj|j��|j|�|jj	|j��|j|�|jj|j�|jj�|j|�y)NrmrnrdF)rhr�rorir�rLrgrKrr@rfr�r:rB�rDrrs  rH�test_flush_on_closez%MemoryHandlerTest.test_flush_on_close�sf��	�	
�����d�/�/�1�2����b�!������T�.�.�0�1����b�!����%�%�d�m�m�4��
�
������
��	
���e�$��(�(�6�6�r�7�?�?�7;�~�~�7<�>��
�	
���"�"�4�=�=�1������d�/�/�1�2����e�$������T�.�.�0�1����e�$����%�%�d�m�m�4��
�
�������e�$rjc���	|jj|j��|jg�|jj	|j��|jg�tjt
jj|j�g��ddg}|j|�t
jjdt
j|jd�|_	|jj|j�|jj|j��|j|�|jj	|j��|j|�tjt
jj|j�g��|j|�y)N��handlerListrmrnrdF)rhr�rorir�rr�weakref�refrgr@rfr�r:rBrws  rH�test_shutdown_flush_on_closez.MemoryHandlerTest.test_shutdown_flush_on_close�sb��	�	
�����d�/�/�1�2����b�!������T�.�.�0�1����b�!����g�o�o�&9�&9�$�-�-�&H�%I�J���
��	
���e�$��(�(�6�6�r�7�?�?�7;�~�~�7<�>��
�	
���"�"�4�=�=�1������d�/�/�1�2����e�$������T�.�.�0�1����e�$����g�o�o�&9�&9�$�-�-�&H�%I�J����e�$rjc���Gd�d�}||j�}	|jj|�td�D]M}tjd�|j
j
d�|j
jd��O	|jD]}tj|��y#|jD]}tj|��wxYw)Nc��eZdZd�Zd�Zd�Zy)�ZMemoryHandlerTest.test_race_between_set_target_and_flush.<locals>.MockRaceConditionHandlerc� �||_g|_yr�)rg�threads)rDrgs  rHr�zcMemoryHandlerTest.test_race_between_set_target_and_flush.<locals>.MockRaceConditionHandler.__init__�s�� (��
�!��rjc�:�|jjd�yr�)rg�	setTargetrns rH�removeTargetzgMemoryHandlerTest.test_race_between_set_target_and_flush.<locals>.MockRaceConditionHandler.removeTarget�s���
�
�'�'��-rjc��tj|j��}|jj	|�|j�y)N)r�)r�r�r�r�r_r�)rDr�threads   rHrVzaMemoryHandlerTest.test_race_between_set_target_and_flush.<locals>.MockRaceConditionHandler.handle�s3��"�)�)��1B�1B�C�����#�#�F�+����rjN)rqrrrsr�r�rVrtrjrH�MockRaceConditionHandlerr��s��
"�
.�
rjr�rdr�znot flushed�flushed)rgr�rxryr{rhr�r�r�r	r)rDr�r�r�r�s     rH�&test_race_between_set_target_and_flushz8MemoryHandlerTest.test_race_between_set_target_and_flush�s���	�	�*�$�-�-�8��		5��M�M�#�#�F�+��2�Y�
3���
�
�5�!����$�$�]�3����'�'�	�2�
3�
!�.�.�
5�� �,�,�V�4�
5��&�.�.�
5�� �,�,�V�4�
5�s�A6B<�<(C$N)rqrrrsrWrIrSrurxr~r	r�r�rtrjrHrbrb�sF��&�3��2� �%�8%�<%�:1��0�0�2�5�3�5rjrbc��eZdZ	d�Zy)�ExceptionFormatterc�&�d|djzS)Nz
Got a [%s]r)rq)rD�eis  rH�formatExceptionz"ExceptionFormatter.formatException
s���b��e�n�n�,�,rjN)rqrrrsr�rtrjrHr�r�s
��(�-rjr�c�N�|j�tj|�yr��rKr1�remove)rRr5s  rH�closeFileHandlerr�s���G�G�I��I�I�b�Mrjc�6�eZdZ	ejZdZdZdZdZejdd�Z
ejdd�Zd	ezd
zZejdd�Z
d
ZdZdZdZdZd�Zd�Zd�Zefd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$y$)%�ConfigFileTest�^(\w+) \+\+ (\w+)$aN
    [loggers]
    keys=root

    [handlers]
    keys=hand1

    [formatters]
    keys=form1

    [logger_root]
    level=WARNING
    handlers=hand1

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stdout,)

    [formatter_form1]
    format=%(levelname)s ++ %(message)s
    datefmt=
    a�
    [loggers]
    keys=root,parser

    [handlers]
    keys=hand1

    [formatters]
    keys=form1

    [logger_root]
    level=WARNING
    handlers=

    [logger_parser]
    level=DEBUG
    handlers=hand1
    propagate=1
    qualname=compiler.parser

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stdout,)

    [formatter_form1]
    format=%(levelname)s ++ %(message)s
    datefmt=
    a�
    [loggers]
    keys=root,parser

    [handlers]
    keys=hand1

    [formatters]
    keys=form1

    [logger_root]
    level=WARNING
    handlers=hand1

    [logger_parser]
    level=DEBUG
    handlers=
    propagate=1
    qualname=compiler.parser

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stdout,)

    [formatter_form1]
    format=%(levelname)s ++ %(message)s
    datefmt=
    z
sys.stdoutz
sys.stboutzformatter=form1zformatter=misspelled_namea
    [loggers]
    keys=root

    [handlers]
    keys=hand1

    [formatters]
    keys=form1

    [logger_root]
    level=NOTSET
    handlers=hand1

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stdout,)

    [formatter_form1]
    class=zS.ExceptionFormatter
    format=%(levelname)s:%(name)s:%(message)s
    datefmt=
    zclass=StreamHandlerzclass=logging.StreamHandlerag
    [loggers]
    keys=root,parser

    [handlers]
    keys=hand1, hand2

    [formatters]
    keys=form1, form2

    [logger_root]
    level=WARNING
    handlers=

    [logger_parser]
    level=DEBUG
    handlers=hand1
    propagate=1
    qualname=compiler.parser

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stdout,)

    [handler_hand2]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stderr,)

    [formatter_form1]
    format=%(levelname)s ++ %(message)s
    datefmt=

    [formatter_form2]
    format=%(message)s
    datefmt=
    a%
    [loggers]
    keys=root,parser,compiler

    [handlers]
    keys=hand1

    [formatters]
    keys=form1

    [logger_root]
    level=WARNING
    handlers=hand1

    [logger_compiler]
    level=DEBUG
    handlers=
    propagate=1
    qualname=compiler

    [logger_parser]
    level=DEBUG
    handlers=
    propagate=1
    qualname=compiler.parser

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    kwargs={'stream': sys.stdout,}

    [formatter_form1]
    format=%(levelname)s ++ %(message)s
    datefmt=
    a
    [loggers]
    keys=root

    [handlers]
    keys=file

    [formatters]
    keys=

    [logger_root]
    level=DEBUG
    handlers=file

    [handler_file]
    class=FileHandler
    level=DEBUG
    args=("{tempfile}",)
    kwargs={{"encoding": "utf-8"}}
    ap
    [loggers]
    keys=root

    [handlers]
    keys=hand1

    [formatters]
    keys=form1

    [logger_root]
    level=WARNING
    handlers=hand1

    [handler_hand1]
    class=StreamHandler
    level=NOTSET
    formatter=form1
    args=(sys.stdout,)

    [formatter_form1]
    format=%(message)s ++ %(customfield)s
    defaults={"customfield": "defaultvalue"}
    z�
    [loggers]
    keys=root

    [handlers]
    keys=screen

    [formatters]
    keys=

    [logger_root]
    level=DEBUG
    handlers=screen

    [handler_screen]
    level=DEBUG
    class=StreamHandler
    args=(sys.stdout,)
    formatter=
    c��tjtj|��}t	j
j|fddi|��y)NrHrF)r4r5�textwrap�dedentr�config�
fileConfig)rD�confr3�files    rH�apply_configzConfigFileTest.apply_config.s5���{�{�8�?�?�4�0�1�����!�!�$�C��C�F�Crjc�z�tj�5}|j|j�t	j
�}|j
|j��|j|j��|jdg|��|jg�ddd�y#1swYyxYw�N�r}r~r�)
r�captured_stdoutr��config0rrr�ror�ri�rD�outputr�s   rH�test_config0_okzConfigFileTest.test_config0_ok2s���
�
$�
$�
&�	&�&����d�l�l�+��&�&�(�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!��#��
"�
�
�!�!�"�%�	&�	&�	&�s�BB1�1B:c�0�tj�5}tjt	j
|j��}tj�}|j|�tjj|�tj�}|j|j��|j!|j��|j#dg|��|j#g�ddd�y#1swYyxYwr�)rr�r4r5r�r�r��configparser�ConfigParser�	read_filerr�r�rr�ror�ri)rDr�r��cpr�s     rH�test_config0_using_cp_okz'ConfigFileTest.test_config0_using_cp_okAs���
�
$�
$�
&�	&�&��;�;�x���t�|�|�<�=�D��*�*�,�B��L�L����N�N�%�%�b�)��&�&�(�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!��#��
"�
�
�!�!�"�%�	&�	&�	&�s�C.D�Dc�j�tj�5}|j|�tjd�}|j|j
��|j|j
��|jddg|��|jg�ddd�y#1swYyxYw�N�compiler.parser�r�r|r�r��	rr�r�rrr�ror�ri�rDr�r�r�s    rH�test_config1_okzConfigFileTest.test_config1_okS���
�
$�
$�
&�	&�&����f�%��&�&�'8�9�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!���#��
"�
�

�!�!�"�%�	&�	&�	&���BB)�)B2c�Z�|jt|j|j�yr��r=r�r��config2rns rH�test_config2_failurez#ConfigFileTest.test_config2_failureb������)�T�%6�%6����Erjc�Z�|jt|j|j�yr��r=r�r��config3rns rH�test_config3_failurez#ConfigFileTest.test_config3_failurefr�rjc��tj�5}|j|j�t	j
�}	t
��#t$rt	jd�YnwxYwtjjd�|j|j�d�|jg�ddd�y#1swYyxYw�N�just testingr�-ERROR:root:just testing
Got a [RuntimeError]
)rr�r��config4rrr��	exceptionrP�stdout�seekrZrXrir�s   rH�test_config4_okzConfigFileTest.test_config4_okjs���
�
$�
$�
&�	&�&����d�l�l�+��&�&�(�F�
2�"�n�$���
2��!�!�.�1�
2���J�J�O�O�A�����V�_�_�.�A�
C�
�!�!�"�%�	&�	&�	&�s*�0C
�
A�A1�.C
�0A1�1AC
�
Cc�<�|j|j��y�N�r�)r��config5rns rH�test_config5_okzConfigFileTest.test_config5_oky������D�L�L��1rjc�<�|j|j��yr�)r��config6rns rH�test_config6_okzConfigFileTest.test_config6_ok|r�rjc�|�tj�5}|j|j�t	j
d�}t	j
d�}|j
|j��|j|j��|j|j��|jgd�|��|jg�ddd�tj�5}|j|j�t	j
d�}|j|j�|j
|j��|j|j��t	j
d�}|j
|j��|j|j��j|j��|jgd�|��|jg�ddd�y#1swY��IxYw#1swYyxYw)Nr��compiler-hyphenated�r�r�)r{rr��compiler.lexer�)r�r�)r}r�)r�r�)r}r�)rr�r��config1arrr�ror��criticalri�config7rWr�rDr�r��
hyphenateds    rH�test_config7_okzConfigFileTest.test_config7_oks���
�
$�
$�
&�	&�&����d�m�m�,��&�&�'8�9�F�!�*�*�+@�A�J��K�K��)�)�+�,��L�L��*�*�,�-����� 1� 1� 3�4��!�!�#��	
"�
�
�!�!�"�%�'	&�(�
$�
$�
&�	&�&����d�l�l�+��&�&�'8�9�F����V�_�_�-��K�K��)�)�+�,��L�L��*�*�,�-��&�&�'7�8�F��K�K��)�)�+�,��L�L��*�*�,�-����� 1� 1� 3�4��!�!�#�
�
"�
�
�!�!�"�%�)	&�	&�)	&�	&��(	&�	&�s�C	H%�:D"H2�%H/�2H;c��|j�5tdd�}tjdk(r|j	dd�}|j
j
|��}|j|�|j|�ddd�tjjd}|jt|�y#1swY�>xYw)Nr��test_logging-X-rs�\z\\)r/r)
�check_no_resource_warningr6r1rF�replace�config8r r�r�rootr@r�r�)rDr5r�r�s    rH�test_config8_okzConfigFileTest.test_config8_ok�s���
�
+�
+�
-�	'���(9�:�B��w�w�$���Z�Z��f�-���l�l�)�)�2�)�6�G����g�&����g�&�	'��,�,�'�'��*�����(�'�2�6�	'�	'�s�A0B>�>Cc�j�|j|j�tjjdj
}|j
tjddi��}|j|d�|j
tjddd���}|j|d�y)Nrr�testztest ++ defaultvalue�customvalue�r�customfieldztest ++ customvalue)	r��config9rr�r@�	formatterr r�rZ)rDr��results   rH�test_config9_okzConfigFileTest.test_config9_ok�s������$�,�,�'��L�L�)�)�!�,�6�6�	��!�!�'�"7�"7����"H�I������!7�8��!�!�'�"7�"7��=�9�#;�<������!6�7rjc�v�|j|j�tjd�}|j	|j
�|j|j�|j
|j
�|j|jd��|j	|j
�y)N�some_pristine_loggerF)�disable_existing_loggers)r��disable_testrrrWrrC�rDr�s  rH�test_logger_disablingz$ConfigFileTest.test_logger_disabling�s������$�+�+�,��"�"�#9�:��������)����$�+�+�,�������(����$�+�+�e��L�������)rjc��d}|j|�|jtj�jdj
d�y)Naw
            [loggers]
            keys=root

            [handlers]
            keys=hand1

            [formatters]
            keys=form1

            [logger_root]
            handlers=hand1

            [handler_hand1]
            class=StreamHandler
            formatter=form1

            [formatter_form1]
            format=%(levelname)s ++ %(message)s
            r�hand1)r�rZrrr@rF)rD�test_configs  rH�test_config_set_handler_namesz,ConfigFileTest.test_config_set_handler_names�sC����(	
���+�&�����*�*�,�5�5�a�8�=�=�w�Grjc��d}tjtj|��}|j	t
tjj|�y)Na�
            [loggers]
            keys=root

            [handlers]
            keys=hand1

            [formatters]
            keys=form1

            [logger_root]
            handlers=hand1

            [handler_hand1]
            class=StreamHandler
            formatter=form1

            [formatter_form1]
            format=%(levelname)s ++ %(message)s

            prince
            )	r4r5r�r�r=r�rr�r�)rDr�r�s   rH�'test_exception_if_confg_file_is_invalidz6ConfigFileTest.test_exception_if_confg_file_is_invalid�s>����.�{�{�8�?�?�;�7�8�����,����(A�(A�4�Hrjc���tjdd��\}}tj|�|j	t
tjj|�tj|�y)N�test_empty_�.ini�r��suffix)
r/r0r1rKr=r�rr�r�r�)rDr4r5s   rH�%test_exception_if_confg_file_is_emptyz4ConfigFileTest.test_exception_if_confg_file_is_emptysJ���!�!��v�F���B�
��������,����(A�(A�2�F�
�	�	�"�
rjc�b�|jttjjd�y)N�filenotfound)r=�FileNotFoundErrorrr�r�rns rH�,test_exception_if_config_file_does_not_existz;ConfigFileTest.test_exception_if_config_file_does_not_exists�����+�W�^�^�-F�-F��Wrjc
��	tjd�j�}tjdd��\}}	tj||jd��tj|�tjj|dtddd	d
ddd
�i����tj|�y#tj|�wxYw)Nat
            [formatters]
            keys=default

            [formatter_default]

            [handlers]
            keys=console

            [handler_console]
            class=logging.StreamHandler
            args=tuple()

            [loggers]
            keys=root

            [logger_root]
            formatter=default
            handlers=console
            �
test_logging_r�r��asciirFrlFr:z5%(asctime)s [%(process)d] [%(levelname)s] %(message)sz[%Y-%m-%d %H:%M:%S %z]zlogging.Formatter)r �datefmt�class)�versionr��
formatters)rH�defaults)r�r��stripr/r0r1r��encoderKrr�r��dictrR)rD�inir4r5s    rH�!test_defaults_do_no_interpolationz0ConfigFileTest.test_defaults_do_no_interpolations���<��o�o���&���'	�(�!�!���H���B�	��H�H�R����G�,�-��H�H�R�L��N�N�%�%�� ���-2�!�&]�'?�%8�$� �
�
&�
� 
�I�I�b�M��B�I�I�b�M�s
�A.C�CN)%rqrrrsr
r�rWr��config1r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrtrjrHr�r�s��?� /� I� I��,���G�4�G�@�H�@�o�o�l�L�9�G��o�o�/�1L�M�G��*�+�*�+�G�6�o�o�3�5R�S�G�'�G�T#�G�L�G�,�G�2�L�*D�
&�&�$&-�
&�F�F�
&�2�2�)&�V7�$8�*�H�0I�6�X�*rjr�c�4�eZdZ	eZdZd�Zd�Zd�Zd�Z	d�Z
y)�SocketHandlerTest�rOrc��	tj|�dx|_x|_|_	|j|j|jd�x|_}|j�|jj�tjj}t|j t"�r|d|j$�|_n||j d�|_d|_|j(j+|j(jd�|j(j-|j�t/j0d�|_y#t$r}||_Yd}~yd}~wwxYw�N�{�G�z�?rOrr)rrIr�	sock_hdlr�server_exception�server_class�address�
handle_socketr�r^rr�rr@�
SocketHandler�
isinstance�server_addressr_r��
log_outputr1rLrBr��	SemaphorerZ�rDrr(�hclss    rHrIzSocketHandlerTest.setUpAs/��	7����t��?C�C���C�d�n�t�'<�	�#'�#4�#4�T�\�\�59�5G�5G��$O�
O�D�K�&��L�L�N�	���������-�-���f�+�+�U�3�!�+�v�{�{�;�D�N�!�&�"7�"7��>�D�N�������&�&�t�'7�'7�'@�'@��'C�D����#�#�D�N�N�3� �*�*�1�-�����	�$%�D�!���	�s�>E#�#	E=�,E8�8E=c�H�		|jr?|jj|j�|jj�|jr|jj�tj|�y#tj|�wxYwr�)rr1rLrKrrrrSrns rHrSzSocketHandlerTest.tearDown[sm��&�	$��~�~�� � �.�.�t�~�~�>����$�$�&��{�{���� � �"����d�#��H���d�#���A1B
�
B!c��|j}	|jd�}t|�dkrytjd|�d}|j|�}t|�|kr/||j|t|�z
�z}t|�|kr�/tj|�}tj|�}|xj|jdzz
c_	|jj���)Nrw�>Lr�
)
�
connection�recvr[�struct�unpack�pickle�loadsrr�r rrZr�)rD�request�conn�chunk�slen�objr�s       rHrzSocketHandlerTest.handle_socketfs����!�!����I�I�a�L�E��5�z�A�~���=�=��u�-�a�0�D��I�I�d�O�E��e�*�t�#���	�	�$��U��*;� <�<���e�*�t�#��,�,�u�%�C��*�*�3�/�F��O�O�v�z�z�D�0�0�O��L�L� � �"�rjc�`�|jr|j|j�tjd�}|j	d�|j
j
�|jd�|j
j
�|j|jd�y)N�tcpr��eggs�
spam
eggs
)
r�skipTestrrr�rZr�r�rZr r�s  rH�test_outputzSocketHandlerTest.test_outputusy��� � ��M�M�$�/�/�0��"�"�5�)�����V�����������V��������������.�9rjc�R�|jr|j|j�d|j_|jj�	t
d��#t$r|jjd�YnwxYw|jjd�tj�}|j|jj|�tj|jj|z
dz�|jjd�y)Ng@zDeliberate mistakez
Never sentzNever sent, eitherrPzNor this)rr8r�
retryStartrrr�r1r�r�ryr��	retryTimer{)rD�nows  rH�
test_noserverzSocketHandlerTest.test_noserver�s���� � ��M�M�$�/�/�0�%(����!�������	5��3�4�4���	5����&�&�|�4�	5�������3�4��i�i�k�����4�>�>�3�3�S�9��
�
�4�>�>�+�+�c�1�E�9�:������z�*s�A�$B�BN)rqrrrsr+rrrIrSrr9r>rtrjrHrr8s*��*� �L��G�.�4	$�
#�	:�+rjrzUnix sockets requiredc�*�eZdZ	eed�reZd�Zy)�UnixSocketHandlerTestrEc��tj�|_|jtj
|j�tj|�yr�)r�create_unix_domain_namerr�rrRrrIrns rHrIzUnixSocketHandlerTest.setUp��8��$�<�<�>������	�(�(�$�,�,�7�����%rjN)rqrrrs�hasattrr�rGrrIrtrjrHr@r@�s��4��v�y�!�+��&rjr@c�.�eZdZ	eZdZd�Zd�Zd�Zd�Z	y)�DatagramHandlerTestrc��	tj|�dx|_x|_|_	|j|j|jd�x|_}|j�|jj�tjj}t|j t"�r|d|j$�|_n||j d�|_d|_|j(j+|j(jd�|j(j-|j�t/j0�|_y#t$r}||_Yd}~yd}~wwxYwr)rrIrrrrr�handle_datagramr�r^rr�rr@�DatagramHandlerrrr_r�r r1rLrBr�r�rZr"s    rHrIzDatagramHandlerTest.setUp�s+��	7����t��?C�C���C�d�n�t�'<�	�#'�#4�#4�T�\�\�59�5I�5I�4�$Q�
Q�D�K�&��L�L�N�	���������/�/���f�+�+�U�3�!�+�v�{�{�;�D�N�!�&�"7�"7��>�D�N�������&�&�t�'7�'7�'@�'@��'C�D����#�#�D�N�N�3� ���(�����	�$%�D�!���	�s�>E"�"	E<�+E7�7E<c�H�		|jr|jj�|jr?|jj	|j�|jj�tj|�y#tj|�wxYwr�)rrrr1rLrKrrSrns rHrSzDatagramHandlerTest.tearDown�sm��&�	$��{�{���� � �"��~�~�� � �.�.�t�~�~�>����$�$�&����d�#��H���d�#�r%c�,�tjdd�}|jt|�d}t	j
|�}t
j|�}|xj|jdzz
c_|jj�y)Nr'rr()r+�pack�packetr[r-r.rr�r rrZr)rDr/r2rMr3r�s      rHrHz#DatagramHandlerTest.handle_datagram�sk���{�{�4��#������D�	�
�+���l�l�6�"���&�&�s�+�����6�:�:��,�,�������rjc��|jr|j|j�tjd�}|j	d�|j
j
�|j
j�|j	d�|j
j
�|j|jd�y)N�udpr�r6r7)
rr8rrr�rZr�rMrZr r�s  rHr9zDatagramHandlerTest.test_output�s���� � ��M�M�$�/�/�0��"�"�5�)�����V�����������������V��������������.�9rjN)
rqrrrsr9rrrIrSrHr9rtrjrHrFrF�s%��$� �L��G�)�4	$��
:rjrFc�*�eZdZ	eed�reZd�Zy)�UnixDatagramHandlerTestrEc��tj�|_|jtj
|j�tj|�yr�)rrBrr�rrRrFrIrns rHrIzUnixDatagramHandlerTest.setUp�s8��$�<�<�>������	�(�(�$�,�,�7��!�!�$�'rjN�rqrrrsrDr�rLrrIrtrjrHrQrQ�s��7��v�y�!�-��(rjrQc�4�eZdZ	eZdZd�Zd�Zd�Zd�Z	d�Z
y)�SysLogHandlerTestrc��	tj|�dx|_x|_|_	|j|j|jd�x|_}|j�|jj�tjj}t|j t"�r'||j d|j$f�|_n||j �|_d|_|j(j+|j(jd�|j(j-|j�t/j0�|_y#t$r}||_Yd}~yd}~wwxYw)Nrrrj)rrIr�sl_hdlrrrrrHr�r^rr�rr@rZrrr_r�r r1rLrBr�r�rZr"s    rHrIzSysLogHandlerTest.setUp�s7��	7����t��=A�A���A�d�l�T�%:�	�#'�#4�#4�T�\�\�59�5I�5I�4�$Q�
Q�D�K�&��L�L�N�	���������-�-���f�+�+�U�3���!6�!6�q�!9�6�;�;� G�H�D�L��� 5� 5�6�D�L�������&�&�t�'7�'7�'@�'@��'C�D����#�#�D�L�L�1� ���(�����	�$%�D�!���	�s�>E/�/	F	�8F�F	c�H�		|jr|jj�|jr?|jj	|j�|jj�tj|�y#tj|�wxYwr�)rrrWr1rLrKrrSrns rHrSzSysLogHandlerTest.tearDownsm��"�	$��{�{���� � �"��|�|�� � �.�.�t�|�|�<����"�"�$����d�#��H���d�#�r%c�Z�|j|_|jj�yr�)rMr rZr)rDr/s  rHrHz!SysLogHandlerTest.handle_datagram s��!�.�.��������rjc�,�|jr|j|j�tjd�}|j	d�|j
j
tj�|j|jd�|j
j�d|j_
|j	d�|j
j
tj�|j|jd�|j
j�d|j_|j	d�|j
j
tj�|j|jd�y)N�slh�späm�
<11>spämFs	<11>spämuhäm-s<11>häm-späm)rr8rrr�rZr�rr`rZr rMrW�
append_nul�identr�s  rHr9zSysLogHandlerTest.test_output$s��� � ��M�M�$�/�/�0��"�"�5�)�����Y�������'�.�.�/�������*@�A�������"'��������Y�������'�.�.�/�������*<�=�������&��������Y�������'�.�.�/�������*G�Hrjc�B�tjd�}|jj�|jj�|j
d�|jjtj�|j|jd�y)Nr[r\r])rrrWrKrZrMr�r�rr`rZr r�s  rH�test_udp_reconnectionz'SysLogHandlerTest.test_udp_reconnection7sk���"�"�5�)�����������������Y�������'�.�.�/�������*@�ArjN)rqrrrsr9rrrIrSrHr9rartrjrHrUrU�s,��,� �L��G�)�4	$��I�&BrjrUc�*�eZdZ	eed�reZd�Zy)�UnixSysLogHandlerTestrEc��tj�|_|jtj
|j�tj|�yr�)rrBrr�rrRrUrIrns rHrIzUnixSysLogHandlerTest.setUpGrCrjNrSrtrjrHrcrc?s��4��v�y�!�-��&rjrcz$IPv6 support required for this test.c�2��eZdZ	eZdZ�fd�Z�fd�Z�xZS)�IPv6SysLogHandlerTest)z::1rc�h��tj|j_tt
|��yr�)r��AF_INET6rrIr�rfrIr�s �rHrIzIPv6SysLogHandlerTest.setUpVs#���+1�?�?����(�
�#�T�0�2rjc�h��tj|j_tt
|��yr�)r��AF_INETrrIr�rfrSr�s �rHrSzIPv6SysLogHandlerTest.tearDownZs#���+1�>�>����(�
�#�T�3�5rj)	rqrrrsr9rrrIrSr�r�s@rHrfrfMs!���1� �L��G�3�6�6rjrfc� �eZdZ	d�Zd�Zd�Zy)�HTTPHandlerTestc�b�	tj|�tj�|_yr�)rrIr�r�rZrns rHrIzHTTPHandlerTest.setUpcs!��	7����t�� ���(��rjc�|�|j|_t|j�|_|jdk(r9	t	|j
d�}|jj|�|_|jd�|j�|jj�y#d|_Y�GxYw)NrMzContent-Length��)
�commandrrX�log_data�int�headers�rfilera�	post_data�
send_response�end_headersrZr)rDr/�rlens   rH�handle_requestzHTTPHandlerTest.handle_requestis�������� ����.��
��<�<�6�!�
&��7�?�?�+;�<�=��!(���!3�!3�D�!9���	���c�"������������	
&�!%���s�8B0�0	B;c�N�tjd�}|j}|j|jjd�dD�]�}d}|r�	ddl}tjjt�}tjj|dd�}|j|j�}|j|�|j|��}	nd}d}	t!||j"d|�	�x|_}
|
j'�|
j(j+�d
|
j,z}|xr|}tjj/|d|	d�
�|_d|_|j5|j0�dD�](}
|
|j0_|j8j;�d}|j=|�|j8j+�|j?|j2jd�|j?|j@|
�|
dk(r tC|j2jD�}n$tC|jFjId��}|j?|ddg�|j?|ddg�|j?|d|g���+|j$jK�|jj|j0�|j0jM����y#t$rd}Y��CwxYw)N�httprr�r�certdatazkeycert.pem)�cafiler)r"zlocalhost:%dz/frob)�foo�bar)�secure�context�credentials)rLrMr\rLrFrF�funcNamer9r)'rrr1rLr@�sslr1rX�dirname�__file__r��
SSLContext�PROTOCOL_TLS_SERVER�load_cert_chain�create_default_context�ImportErrorrryrr�rr��server_portr`�h_hdlrrqrBrerZrMr�rZrpr�queryru�decoderrK)rDr�r1r�r�r��here�localhost_certr"r�r�host�
secure_clientrer�ds                rHr9zHTTPHandlerTest.test_outputvs����"�"�6�*���&�&���!�!�$�"2�"2�";�";�A�">�?�#�0	 �F�#�D��
P���7�7�?�?�8�4�D�%'�W�W�\�\�$�
�M�%R�N� �^�^�C�,C�,C�D�F��*�*�>�:�!�8�8��8�O�G�����#1�$��8K�8K�48��$I�
I�D�K�&��L�L�N��L�L����!�F�$6�$6�6�D�"�-�v�M�!�*�*�6�6�t�W�>K�?F�CQ�7�S�D�K�!�D�M��"�"�4�;�;�/�)�
2��%+����"����"�"�$������S�!����!�!�#�� � ����!3�!3�W�=�� � ����v�6��U�?� ����!4�!4�5�A� ����!6�!6�w�!?�@�A�� � ��6��V�H�5�� � ��:����@�� � ��5��C�5�1�
2� 
�K�K�������*�*�4�;�;�7��K�K����a0	 ��
#�"�!�F�"�s�L�L$�#L$N)rqrrrsrIryr9rtrjrHrlrl^s�� �)��5 rjrlc�&�eZdZ	d�Zd�Zd�Zd�Zy)�
MemoryTestc�>�	tj|�i|_yr�)rrI�
_survivorsrns rHrIzMemoryTest.setUp�s��F����t����rjc��	|D]:}t|�t|�f}tj|�|j|<�<yr�)rr�r|r}r�)rDr2r3�keys    rH�_watch_for_survivalzMemoryTest._watch_for_survival�s?��	��	4�C��S�'�4��9�$�C�#*�;�;�s�#3�D�O�O�C� �	4rjc��	tj�g}|jj�D]!\\}}}|���|j	|��#|r/|jdt
|�dj|�fz�yy)Nz;%d objects should have survived but have been destroyed: %sz, )�gc�collectr�r�r_r^r[r�)rD�dead�id_�repr_r}s     rH�_assertTruesurvivalzMemoryTest._assertTruesurvival�s���I�
�
�
����!%���!6�!6�!8�	#��L�S�%�#��u�}����E�"�	#���I�I�.�14�T��D�I�I�d�O�0L�M�
N�rjc�D�|jjtj�tjd�}|j|�|jtj�|jj|j��|j|j��|jdg�~|j�tjd�}|j|j��|jddg�y)Nr~)r~r8r~)r~r8r)r1r7rr�rr�r8r�rorir�)rDr~rs   rH�test_persistent_loggersz"MemoryTest.test_persistent_loggers�s���	
���!�!�'�,�,�/�����&��� � ��%����W�]�]�#������t�0�0�2�3��	�	�$�#�#�%�&����!�
�	�
�� � �"�����&���	�	�$�#�#�%�&����!�!�
�	rjN)rqrrrsrIr�r�r�rtrjrHr�r��s��4��
4�
N�rjr�c��eZdZd�Zd�Zy)�EncodingTestc���tjd�}tdd�}d}	tj|d��}|j	|�	|j|�|j
|�|j�t|d��}	|j|j�j�|�|j�	tjj|�rtj|�yy#|j
|�|j�wxYw#|j�wxYw#tjj|�rtj|�wwxYw)Nr�r�ztest_logging-1-ufoo€rFr�)rrr6rlrBr�rLrKr�rZra�rstripr1rX�isfiler�)rDr�r5r�r�r�s      rH�test_encoding_plain_filez%EncodingTest.test_encoding_plain_file�s������'��
�F�$5�
6����	��)�)�"�w�?�G��N�N�7�#�
 ����D�!��!�!�'�*��
�
���R�'�*�A�
�� � �������!2�D�9����	��w�w�~�~�b�!��	�	�"�
�"���!�!�'�*��
�
������	���w�w�~�~�b�!��	�	�"�
�"�s;�(D>�D�.D>�.D)�<D>�#D&�&D>�)D;�;D>�>7E5c���tjd�}d}tjd�}d|_tj�}||d�}tj|�}|j|�	|j|�|j|�|j�|j�}|j|d�y#|j|�|j�wxYw)Nr�uдо свидания�cp1251�stricts�� �������
)rr�codecs�	getwriterrHr4�BytesIOr9rBr�rLrKrXrZ)rDr��message�writer_classr6�writerr�rhs        rH�test_encoding_cyrillic_unicodez+EncodingTest.test_encoding_cyrillic_unicode�s�������'��Q���'�'��1�� (���������f�h�/���'�'��/�����w��	��K�K�� ����g�&��M�M�O��O�O�������J�K��
���g�&��M�M�O�s�8C
�
#C0N)rqrrrsr�r�rtrjrHr�r��s
���2Lrjr�c��eZdZd�Zd�Zy)�WarningsTestc	�*�tj�5tjd�|j	tjd�tj
dt��tj�}tj|�}tjd�}|j|�tjd�|j|�|j�}|j�|j!|j#d�d�tj�}tj$d	td
d|d�|j�}|j�|j'|d
�ddd�y#1swYyxYw)NTF�always)�category�py.warningszI'm warning you...z UserWarning: I'm warning you...
r�Explicit�dummy.py�*z
Dummy linez0dummy.py:42: UserWarning: Explicit
  Dummy line
)�warnings�catch_warningsr�captureWarningsr��filterwarnings�UserWarningr4r5r9rrB�warnrLrXrKr��find�showwarningrZ)rDr6rRr�rh�a_files      rH�
test_warningszWarningsTest.test_warnings	s-��
�
$�
$�
&�	F��#�#�D�)��O�O�G�3�3�U�;��#�#�H�{�C��[�[�]�F��%�%�f�-�A��&�&�}�5�F����a� ��M�M�.�/�� � ��#����!�A�
�G�G�I����q�v�v�&I�J�A�N��[�[�]�F�� � ��[�*�b�!'��
7����!�A��L�L�N����Q�D�
F�)	F�	F�	F�s�E+F	�	Fc��tj�5tjd�|j	tjd�tj
d�}|j
|jg�tjdtdd�|j
t|j�d�|j|jdtj�ddd�y#1swYyxYw)	NTFr�r�r�r�rlr)
r�r�rr�r�rrZr@r�r�r[�assertIsInstance�NullHandlerr�s  rH�test_warnings_no_handlersz&WarningsTest.test_warnings_no_handlers+	s���
�
$�
$�
&�
	K��#�#�D�)��O�O�G�3�3�U�;��&�&�}�5�F����V�_�_�b�1�� � ��[�*�b�I����S����1�1�5��!�!�&�/�/�!�"4�g�6I�6I�J�
	K�
	K�
	K�s�CC3�3C<N)rqrrrsr�r�rtrjrHr�r�	s��F�0Krjr�c�.�tj||�Sr�)rr;)r rs  rH�
formatFuncr�9	s�����V�W�-�-rjc��eZdZdd�Zy)�myCustomFormatterNc��yr�rt)rD�fmtrs   rHr�zmyCustomFormatter.__init__=	s��rjr�)rqrrrsr�rtrjrHr�r�<	s��
rjr�c�*�tj�Sr�)rr9rtrjrH�handlerFuncr�@	s��� � �"�"rjc��eZdZy)�
CustomHandlerN�rqrrrsrtrjrHr�r�C	���rjr�c��eZdZy)�CustomListenerNr�rtrjrHr�r�F	r�rjr�c��eZdZy)�CustomQueueNr�rtrjrHr�r�I	r�rjr�c�*�tj�Sr�)�queue�QueuertrjrH�
queueMakerr�L	s���;�;�=�rjc����fd�}|S)Nc�F��|jd��t|g|��i|��S)N�respect_handler_level)�
setdefaultr�)r�r@r3r�s   �rH�funczlistenerMaker.<locals>.funcP	s*������1�3H�I��e�9�h�9�&�9�9rjrt)�arg1�arg2r�r�s  ` rH�
listenerMakerr�O	s���:��Krjc
��eZdZ	ejZdZddddiiddddd	d
�iddgd�d
�Zddddiiddddd	d
�idddgd�iddid�Zddddiiddddd	d
�idddiiddgd�d�Zddddiidddddd
�idddgd�iddid�Z	ddddiiddddd	d
�idddgd�iddid�Z
ddddiiddddd	d
�idddgd�iddid�Zddddiiddddd	d
�idddgd�iddid�Zddedzdd�iddddd	d
�iddgd�d
�Z
dedd�edzdd�edd�d�dddd	d
�deid�ddgd�d
�Zddddiidedzddd	d
�idddgd�iddid�Zddddiidedzddd	dd�idddgd�iddid�Zddddiiddddd	d
�id ddgd�iddid�Zdd!dddiiddddd	d
�iddgd�id"�ddid#�Zdd$dddiiddddd	d
�iddgd�id"�ddid#�Zddddiiddddd	d
�idddgd�iddid�Zdd$dddiiddd%iid&�Zdd$ddd%iiddd%iid&�Zddddiid'd(diiddddd	d'gd)�iddd'gd*�iddgd�d+�Zddddiiddddd	d
�id,dd-idddgd�iddid.�Zdddiiddddd	d
�id,dd-idddgd�iddid/�Zd0dddiiddddd	d
�id,dd-idddgd�iddid.�Zddddiiddddd	d1d2d3�d4�iddgd�d
�Zddd5d6d7id8�iddddd	d
�iddgd�d
�ZGd9�d:e jB�Z"dd;e"d<d=d>d?d@idA�iddd;dd	d
�iddgd�d
�Z#ddBdCdDdE�idddBdF�dGdHdBdIddJ�dK�dLddMgdNdO�idP�Z$ddedzdd!dQ�iddddd	d
�idRddgdNdO�idP�Z%ddedzdd!dS�iddddd	d
�idRddgdNdO�idP�Z&ddedTzdd!dS�iddddd	d
�idRddgdNdO�idP�Z'ddedd!dQ�iddddd	d
�idRddgdNdO�idP�Z(ddedUd6dVidW�iddddd	d
�idRddgdNdO�idP�Z)ddXdYidZd[gd\�d]�dd^gd�d_�Z*d`�Z+da�Z,db�Z-efdc�Z.dd�Z/de�Z0df�Z1dg�Z2dh�Z3di�Z4dj�Z5dk�Z6dl�Z7dm�Z8dn�Z9do�Z:dp�Z;dq�Z<dr�Z=ds�Z>dt�Z?du�Z@dv�ZAdw�ZBd�dy�ZCeDj��dz��ZFeDj��d{��ZGeDj��d|��ZHd}�ZId~�ZJd�ZKd��ZLd��ZMd��ZNd��ZOd��ZPd��ZQd��ZRd��ZSd��ZTd��ZUd��ZVd��ZWeXj��d���ZZd��Z[d��Z\yx)��ConfigDictTestr�rl�form1r z%(levelname)s ++ %(message)sr��logging.StreamHandlerr�zext://sys.stdout)rr�r�r6r��r�r@)r	r
r@r�r�r8r�)r	r
r@�loggersr�zext://sys.stdbout�NTOSET�WRANING�misspelled_namez.ExceptionFormatterz"%(levelname)s:%(name)s:%(message)s)�()r z.formatFunc)r��form2�form3r�)r��hand2z.CustomHandlerzinvalid parameter name)rr�r�r6r�r�F)�compilerr�)r	r�r
r@r�r�Tr�)r	�incrementalr@r��filt1rF)rr�r�r6�filters�r�r�)r	r
r�r@r�r�zcfg://true_formatterszcfg://handler_configs[hand1])r	�true_formatters�handler_configsr
r@r�r�)r�r�r
r@r�r�r�r�!
)r~�
terminator)rr�r�r6r�z%(message)s ++ %(customfield)sr��defaultvalue)r rc�"��eZdZdZ�fd�Z�xZS)�ConfigDictTest.CustomFormatterr�c�"��t�|�|�Sr�)r�r �rDr�r�s  �rHr z%ConfigDictTest.CustomFormatter.format�s����7�>�&�)�)rj)rqrrrs�custom_propertyr r�r�s@rH�CustomFormatterr�s�����	*�	*rjr�custom�{�%Y-%m-%d %H:%M:%S�	{message}r�value)r��stylerr r��mySimpleFormatterz1%(asctime)s (%(name)s) %(levelname)s: %(message)s�$)r r
)rr�r�zlogging.handlers.MemoryHandler��
fileGlobal)r�capacityr�r�r�)r�bufferGlobal�mymoduler�true)r�r@ri)r	r
r@r�)r�r �validate�my_test_logger_custom_formatter)rr rz.myCustomFormatterz2%(levelname)s:%(name)s:%(message)s:%(customfield)s�myvalue)r�r rr�logging.FileHandler�logging.handlers.QueueHandler�h1)rr@)r�ahr�r	r@r�c�B�tjj|�yr�)rr��
dictConfig)rDr�s  rHr�zConfigDictTest.apply_config�s�����!�!�$�'rjc�R�tj|�}|j||�yr�)r�getHandlerByNamer�)rDrFrqrRs    rH�
check_handlerzConfigDictTest.check_handler�s"���$�$�T�*�����a��%rjc��tj�5}|j|j�|j	dt
j�tj�}|j|j��|j|j��|jdg|��|jg�ddd�y#1swYyxYw)Nr�r�r�)rr�r�r�rrr9rr�ror�rir�s   rHr�zConfigDictTest.test_config0_ok�s���
�
$�
$�
&�	&�&����d�l�l�+����w��(=�(=�>��&�&�(�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!��#��
"�
�
�!�!�"�%�	&�	&�	&�s�B3C�Cc�j�tj�5}|j|�tjd�}|j|j
��|j|j
��|jddg|��|jg�ddd�y#1swYyxYwr�r�r�s    rHr�zConfigDictTest.test_config1_ok�r�r�c�Z�|jt|j|j�yr�r�rns rHr�z#ConfigDictTest.test_config2_failure�r�rjc�Z�|jt|j|j�yr�)r=r�r��config2arns rH�test_config2a_failurez$ConfigDictTest.test_config2a_failure�������)�T�%6�%6��
�
�Frjc�Z�|jt|j|j�yr�)r=r�r��config2brns rH�test_config2b_failurez$ConfigDictTest.test_config2b_failure�r&rjc�Z�|jt|j|j�yr�r�rns rHr�z#ConfigDictTest.test_config3_failure�r�rjc���tj�5}|j|j�|j	dt
j�	t��#t$rtjd�YnwxYwtjjd�|j|j�d�|jg�ddd�y#1swYyxYw)Nr�r�rr�)rr�r�r�rrr9r�r�rPr�r�rZrXri�rDr�s  rHr�zConfigDictTest.test_config4_ok�s���
�
$�
$�
&�	&�&����d�l�l�+����w��(=�(=�>�
2�"�n�$���
2��!�!�.�1�
2���J�J�O�O�A�����V�_�_�.�A�
C�
�!�!�"�%�	&�	&�	&�s*�<C�
A�A=�:C�<A=�=AC�C"c��tj�5}|j|j�	t	��#t$rtjd�YnwxYwtjjd�|j|j�d�|jg�ddd�y#1swYyxYwr�)
rr�r��config4ar�rr�rPr�r�rZrXrir,s  rH�test_config4a_okzConfigDictTest.test_config4a_ok�s���
�
$�
$�
&�	&�&����d�m�m�,�
2�"�n�$���
2��!�!�.�1�
2���J�J�O�O�A�����V�_�_�.�A�
C�
�!�!�"�%�	&�	&�	&�s'�B9�
<�A�B9�A�AB9�9Cc�h�|j|j��|jdt�y)Nr�r�)r�r�rr�rns rHr�zConfigDictTest.test_config5_ok�s'�����D�L�L��1����7�M�2rjc�Z�|jt|j|j�yr�)r=r�r�r�rns rH�test_config6_failurez#ConfigDictTest.test_config6_failure�s�����)�T�%6�%6����Erjc��tj�5}|j|j�t	j
d�}|j
|j��|j|j��|jddg|��|jg�ddd�tj�5}|j|j�|jdtj�t	j
d�}|j|j�t	j
d�}|j
|j��|j|j��|jddg|��|jg�ddd�y#1swY��xYw#1swYyxYw)	Nr�r�r�r�r�r��r�r�r}r�)rr�r�rrrr�ror�rir�rr9rCrr�s   rHr�zConfigDictTest.test_config7_ok�s���
�
$�
$�
&�	&�&����d�l�l�+��&�&�'8�9�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!���#��
"�
�

�!�!�"�%�	&��
$�
$�
&�	&�&����d�l�l�+����w��(=�(=�>��&�&�'8�9�F��O�O�F�O�O�,��&�&�'7�8�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!���#��
"�
�

�!�!�"�%�	&�	&�	&�	&��	&�	&�s�BF4�C%G�4F>�G
c��tj�5}|j|j�t	j
d�}|j
|j��|j|j��|jddg|��|jg�ddd�tj�5}|j|j�|jdtj�t	j
d�}|j|j�|j
|j��|j|j��t	j
d�}|j
|j��|j|j��|jgd�|��|jg�ddd�y#1swY��JxYw#1swYyxYw)Nr�r�r�r�r�r�)r4r5�r�r��r}r�)rr�r�rrrr�ror�rir�rr9rWrr�s   rH�test_config_8_okzConfigDictTest.test_config_8_ok
s���
�
$�
$�
&�	&�&����d�l�l�+��&�&�'8�9�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!���#��
"�
�

�!�!�"�%�	&��
$�
$�
&�	&�&����d�l�l�+����w��(=�(=�>��&�&�'8�9�F����V�_�_�-��K�K��)�)�+�,��L�L��*�*�,�-��&�&�'7�8�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!�#�
�
"�
�
�!�!�"�%�'	&�	&�	&�	&��	&�	&�s�BG2�D#G?�2G<�?Hc��tj�5}|j|j�|j	dt
j�tjd�}tjd�}|j|j��|j|j��|j|j��|jgd�|��|jg�ddd�tj�5}|j|j�|j	dt
j�tjd�}|j|j�|j|j��|j|j��tjd�}|j|j��|j|j��j|j��|jgd�|��|jg�ddd�y#1swY��ixYw#1swYyxYw)Nr�r�r�r�r�r�r�)rr�r�r�rrr9rr�ror�r�ri�config8arWrr�s    rH�test_config_8a_okz ConfigDictTest.test_config_8a_ok=
s���
�
$�
$�
&�	&�&����d�m�m�,����w��(=�(=�>��&�&�'8�9�F�!�*�*�+@�A�J��K�K��)�)�+�,��L�L��*�*�,�-����� 1� 1� 3�4��!�!�#��	
"�
�
�!�!�"�%�)	&�*�
$�
$�
&�	&�&����d�m�m�,����w��(=�(=�>��&�&�'8�9�F����V�_�_�-��K�K��)�)�+�,��L�L��*�*�,�-��&�&�'7�8�F��K�K��)�)�+�,��L�L��*�*�,�-����� 1� 1� 3�4��!�!�#�
�
"�
�
�!�!�"�%�+	&�	&�+	&�	&��*	&�	&�s�C)I%�EI2�%I/�2I;c��tj�5}|j|j�|j	dt
j�tjd�}|j|j��|jg|��|j|j�|j|j��|jg|��|j|j�|j|j��|jdg|��ddd�y#1swYyxYw)Nr�r�r�r4)
rr�r�r�rrr9rr�rori�config9a�config9br�s   rH�test_config_9_okzConfigDictTest.test_config_9_okj
s��
�
$�
$�
&�	�&����d�l�l�+����w��(=�(=�>��&�&�'8�9�F��K�K��)�)�+�,��!�!�"�V�!�4����d�m�m�,��K�K��)�)�+�,��!�!�"�V�!�4����d�m�m�,��K�K��)�)�+�,��!�!��#��
"�
�	�	�	�s�DD<�<Ec��tj�5}|j|j�|j	dt
j�tjd�}|j|j��tjd�}|j|j��tjd�}|j|j��tjd�}|j|j��|jddg|��ddd�y#1swYyxYw�	Nr�r�r�r�zcompiler.parser.codegen)r�r|r5r�)rr�r��config10rrr9rr�ror�rir�s   rH�test_config_10_okz ConfigDictTest.test_config_10_ok}
s��
�
$�
$�
&�	�&����d�m�m�,����w��(=�(=�>��&�&�'8�9�F��N�N�4�,�,�.�/��&�&�z�2�F��N�N�4�,�,�.�/��&�&�'7�8�F��N�N�4�,�,�.�/��&�&�'@�A�F��L�L��*�*�,�-��!�!� ��#��
"�
�	�	�	�s�D!D?�?Ec�:�|j|j�yr�)r��config11rns rH�test_config11_okzConfigDictTest.test_config11_ok�
s�����T�]�]�+rjc�Z�|jt|j|j�yr�)r=r�r��config12rns rH�test_config12_failurez$ConfigDictTest.test_config12_failure�
������)�T�%6�%6��
�
�Frjc�Z�|jt|j|j�yr�)r=r�r��config13rns rH�test_config13_failurez$ConfigDictTest.test_config13_failure�
rKrjc��tj�5}|j|j�tj
d}|j
|jd�|j
|jd�t	jd�|j|j�jd��ddd�y#1swYyxYw)Nr�rr��Exclamationz
Exclamation!
)
rr�r��config14rr"rZr~r�r�rCrXr\)rDr�rRs   rH�test_config14_okzConfigDictTest.test_config14_ok�
s���
�
$�
$�
&�	J�&����d�m�m�,��!�!�'�*�A����Q�U�U�E�*����Q�\�\�5�1��O�O�M�*��O�O�F�O�O�-�6�6�7G�H�I�
	J�	J�	J�s�B*C�Cc�0�|j�5tdd�}ddd|dd�iddgid	�}|j|�|j|�ddd�tjj
d
}|j
t|�y#1swY�>xYw)Nr�r�rlr�rrF)r�filenamerHr@rr)r�r6r�rr�r@r�r�)rDr5r�r�s    rH�test_config15_okzConfigDictTest.test_config15_ok�
s���
�
+�
+�
-�	&���(9�:�B���!6�$&�$+��������F�
���f�%����f�%�%	&�(�,�,�'�'��*�����(�'�2�6�+	&�	&�s�>B�Bc�j�|j|j�tjd}|jjtjddd���}|j|d�|jjtjddi��}|j|d�y)Nr��Hellor�r�zHello ++ customvaluerzHello ++ defaultvalue)r��config16rr"r�r r�rZ)rDrRr�s   rH�test_config16_okzConfigDictTest.test_config16_ok�
s������$�-�-�(����g�&�����#�#�G�$9�$9��M�:�%<�=������!7�8����#�#�G�$9�$9�
�G��%�������!8�9rjc��|j|j�tjd}|j	|j
jd�y)Nr�r	)r��config17rr"rZr�rr@s  rH�test_config17_okzConfigDictTest.test_config17_ok�
s>�����$�-�-�(����g�&��������4�4�g�>rjNc���|jd�}tjjd|�}|j	�|j
j
�|j}|j
j�	tjtjtj�}|jd�|jd|f�tjdt!|��}||z}d}t!|�}	|	dkDr$|j#||d�}
||
z
}|	|
z}	|	dkDr�$|j%�|j
j
d�tjj'�t)j*|�y#|j
j
d�tjj'�t)j*|�wxYw)NrFrg@rOr')r
rr��listenr�rr�r�rMr�rj�SOCK_STREAM�
settimeout�connectr+rLr[�sendrK�
stopListeningr	r)rD�text�verifyr�r�r'r2rh�	sentsofar�left�sents           rH�setup_via_listenerz!ConfigDictTest.setup_via_listener�
s[���{�{�7�#���N�N�!�!�!�V�,��	���	�	�������v�v��	���
�
��	,��=�=�����1C�1C�D�D��O�O�C� ��L�L�+�t�,�-��;�;�t�S��Y�/�D��t��A��I��q�6�D���(��y�y��9�:��/���T�!�	�������(�
�J�J�L�
�G�G�L�L����N�N�(�(�*��(�(��+��
�G�G�L�L����N�N�(�(�*��(�(��+�s�B/F�3F�AG"c��tj�5}|jtj|j
��|j
dtj�tjd�}|j|j��tjd�}|j|j��tjd�}|j|j��tjd�}|j|j��|jddg|��ddd�y#1swYyxYwrB)rr�ri�json�dumpsrCrrr9rr�ror�rir�s   rH�test_listen_config_10_okz'ConfigDictTest.test_listen_config_10_ok�
s��
�
$�
$�
&�	�&��#�#�D�J�J�t�}�}�$=�>����w��(=�(=�>��&�&�'8�9�F��N�N�4�,�,�.�/��&�&�z�2�F��N�N�4�,�,�.�/��&�&�'7�8�F��N�N�4�,�,�.�/��&�&�'@�A�F��L�L��*�*�,�-��!�!� ��#��
"�
�	�	�	�s�D4E�Ec��tj�5}|jtjt
j��tjd�}|j|j��|j|j��|jddg|��|jg�ddd�y#1swYyxYwr�)
rr�rir�r�r�rrrr�ror�rir�s   rH�test_listen_config_1_okz&ConfigDictTest.test_listen_config_1_oks���
�
$�
$�
&�	&�&��#�#�H�O�O�N�4J�4J�$K�L��&�&�'8�9�F��K�K��)�)�+�,��L�L��*�*�,�-��!�!���#��
"�
�

�!�!�"�%�	&�	&�	&�s�B,C
�
Cc��d�}d�}tjd�}tjtj
�}t
j�5}|j||�|j|j��|j|j��ddd�|jg��|jddgd��t
j�5}|j|�tjd�}|j|j��|j|j��ddd�|jd	d
g|��|jddgd��t
j�5}|j|ddd�|�tjd�}|j|j��|j|j��ddd�|jdd
g|��|jddgd��y#1swY���xYw#1swY��xYw#1swY�MxYw)Nc��yr�rt��stuffs rH�verify_failz6ConfigDictTest.test_listen_verify.<locals>.verify_fails��rjc��|ddd�S)NrJrtrrs rH�verify_reversez9ConfigDictTest.test_listen_verify.<locals>.verify_reverses����2��;�rjr�r�r�r�r�)rcr4r5rJr7r8)
rrr�r�r�rrr�rir�ror�ri)rDrtrvr��to_sendr�s      rH�test_listen_verifyz!ConfigDictTest.test_listen_verifysE��	�	��"�"�#4�5���/�/�.�"8�"8�9���
$�
$�
&�	.�&��#�#�G�[�9��K�K��)�)�+�,��L�L��*�*�,�-�		.�
	
���b���0������
�+�	�	,��
$�
$�
&�	.�&��#�#�G�,��&�&�'8�9�F��K�K��)�)�+�,��L�L��*�*�,�-�	.�	
�����
��	�	�
	
�����
�+�	�	,��
$�
$�
&�	.�&��#�#�G�D�b�D�M�>�B��&�&�'8�9�F��K�K��)�)�+�,��L�L��*�*�,�-�	.�	
�����
��	�	�
	
�����
�+�	�	,�Y	.�	.��	.�	.��$	.�	.�s'�AH2�(A%H?�A,I�2H<�?I�Ic�Z�|jt|j|j�yr�)r=r_r��
bad_formatrns rH�test_bad_formatzConfigDictTest.test_bad_formatNs�����*�d�&7�&7����Irjc���tj|j�}d|ddd<|j|�t	j
d�jd}|j|jtj�|j|jjtj�|jtt	j��ddg�y)	Nz-${asctime} (${name}) ${levelname}: ${message}r
rr rrrr)r#�deepcopyrzr�rrr@r�r�r<r��_style�StringTemplateStylerZ�sorted�getHandlerNames�rDr�r�s   rH�!test_bad_format_with_dollar_stylez0ConfigDictTest.test_bad_format_with_dollar_styleQs������t���/��>m��|��0�1�(�;����&�!��#�#�J�/�8�8��;�����g�n�n�g�o�o�>����g�/�/�6�6�%�9�9�	;������ 7� 7� 9�:�(�,�7�	9rjc��|j|j�tjd�jd}|j|jt�y�Nrr)r��custom_formatter_class_validaterrr@r�r�r��rDr�s  rH�)test_custom_formatter_class_with_validatez8ConfigDictTest.test_custom_formatter_class_with_validate]sJ�����$�>�>�?��#�#�$E�F�O�O�PQ�R�����g�/�/�1C�Drjc��|j|j�tjd�jd}|j|jt�yr�)r�� custom_formatter_class_validate2rrr@r�r�r�r�s  rH�*test_custom_formatter_class_with_validate2z9ConfigDictTest.test_custom_formatter_class_with_validate2bsJ�����$�?�?�@��#�#�$E�F�O�O�PQ�R�����g�/�/�1C�Drjc���|jj�}d|ddd<|j|�tjd�j
d}|j
|jt�y)Nrr
r�r
rr)	r�r#r�rrr@r�r�r�r�s   rH�9test_custom_formatter_class_with_validate2_with_wrong_fmtzHConfigDictTest.test_custom_formatter_class_with_validate2_with_wrong_fmtgsn���5�5�:�:�<��14��|��W�%�g�.�	
���&�!��#�#�$E�F�O�O�PQ�R�����g�/�/�1C�Drjc�Z�|jt|j|j�yr�)r=r_r�� custom_formatter_class_validate3rns rH�*test_custom_formatter_class_with_validate3z9ConfigDictTest.test_custom_formatter_class_with_validate3ps �����*�d�&7�&7��9^�9^�_rjc�Z�|jt|j|j�yr�)r=r_r��custom_formatter_with_functionrns rH�,test_custom_formatter_function_with_validatez;ConfigDictTest.test_custom_formatter_function_with_validates� �����*�d�&7�&7��9\�9\�]rjc�Z�|jt|j|j�yr�)r=r_r��custom_formatter_with_defaultsrns rH�,test_custom_formatter_function_with_defaultsz;ConfigDictTest.test_custom_formatter_function_with_defaultsvr�rjc�&�dgd�ddd�dddd	gd
ggd�d�}tjj|�}|j|j	d
�d�|j|j	d�d�|j|j	d�d�|j|j	d�d	�|j|j	d�d�|j|j	d�d�|j	d�}|j|jd�gd��|j
t|jd�|j
t|jd�|j
t|jd�y)N)rlr��)ri�b�cr(r�)r�r�)�g)rRrt�jr��lr�rs)�ozcfg://alist�p)�atuple�alist�adict�nest1�nest2�nest3zcfg://atuple[1]r�zcfg://alist[1]r�zcfg://nest1[1][0]rRzcfg://nest2[1][1]z
cfg://adict.dzcfg://adict[f]zcfg://nest3rlzcfg://nosuchzcfg://!zcfg://adict[2])	rr��BaseConfiguratorrZ�convert�popr=�KeyErrorr_)rDr��bcr�s    rH�test_baseconfigzConfigDictTest.test_baseconfigysE���$��Q�(�+��C��:�s�+�.�

���^�^�
,�
,�Q�
/��������$5�6��:�������$4�5�s�;�������$7�8�#�>�������$7�8�#�>�������O�4�c�:�������$4�5�q�9��J�J�}�%��������q��?�3����(�B�J�J��?����*�b�j�j�)�<����(�B�J�J�0@�Arjc�p��ddlm�G�fd�dtj�}�dddg�}|dd	g�
�}dd||d
�iddgd�d�}t	j
�5}|j
|�tjd�ddd�|jj�d�y#1swY�*xYw)Nr)�
namedtuplec�,���eZdZ��fd�Z�fd�Z�xZS)�1ConfigDictTest.test_namedtuple.<locals>.MyHandlerc�2��t�|�|i|��||_yr�)r�r��resource)rDr�r2r3r�r�s    ��rHr�z:ConfigDictTest.test_namedtuple.<locals>.MyHandler.__init__�s����� �$�1�&�1�,4��
rjc�z��|xjd|jj��z
c_t�|�|�S�N� )rr��typer�r?rs  �rHr?z6ConfigDictTest.test_namedtuple.<locals>.MyHandler.emit�s2����
�
��$�-�-�"4�"4�!5�6�6�
��w�|�F�+�+rjr�)r�r�s@�rH�	MyHandlerr��s���
5�
,�
,rjr��Resourcer��labels�my_typeri)r�r�rl�	myhandler)r�r�r�r�rzsome logzsome log my_type
)
�collectionsr�rr9rr�r�r�rZrX)rDr�r�r�r�r�r�s      @rH�test_namedtuplezConfigDictTest.test_namedtuple�s����*�	,��-�-�	,��j�6�8�*<�=����C�5�9����#� (��� &�K�=�A�	
���
$�
$�
&�	%�&����f�%��L�L��$�	%�	
������*�,@�A�	%�	%�s�'B,�,B5c�l�d�}|jdd|gd�d��gtj�_y)Nc��yr3rt)r�s rHr�zAConfigDictTest.test_config_callable_filter_works.<locals>.filter_�s��rjrlr8r��r	r��r�rrr��rDr�s  rH�!test_config_callable_filter_worksz0ConfigDictTest.test_config_callable_filter_works�s9��	�����G��	�"J�
�	�')�����#rjc��tjd�}|jdd|gd�d��gtj�_y)Nr�rlr8r�r�)rr�r�rr�r�s  rH�test_config_filter_worksz'ConfigDictTest.test_config_filter_works�sB���.�.��-������G��	�"J�
�	�')�����#rjc��Gd�d�}|�}|jdd|gd�d��gtj�_y)Nc��eZdZd�Zy)�BConfigDictTest.test_config_filter_method_works.<locals>.FakeFilterc��yr3rt)rDr�s  rHr�zIConfigDictTest.test_config_filter_method_works.<locals>.FakeFilter.filter�s��rjNr�rtrjrH�
FakeFilterr��s��
rjr�rlr8r�r�r�)rDr�r�s   rH�test_config_filter_method_worksz.ConfigDictTest.test_config_filter_method_works�sG��	�	��,������G��	�"J�
�	�')�����#rjc	��Gd�d�}dd|�fD]*}|jt|jdd|gd�d���,y)Nc��eZdZy)�;ConfigDictTest.test_invalid_type_raises.<locals>.NotAFilterNr�rtrjrH�
NotAFilterr��s�rjr�rlr8r�r�)r=r_r�)rDr�r�s   rH�test_invalid_type_raisesz'ConfigDictTest.test_invalid_type_raises�sI�����a���.�	�G������!�!���g�Y�'O�P�
�	rjc��tj|j�}tdd�}||ddd<|�||ddd<|�||ddd<d}	|j	|�tjd�}|jttj��ddg�|j|j�|jj�tjd	�tjd
�tjd�t!j"t j$d�rJ|jj&j)�rn%t!j"t j$d�r�J|jj&j+�t-|d
��5}|j/�j1�}ddd�|jgd��|r|jj3�tjd�}|r|j5t6||�y|j5t8j:|�y#1swY��xYw#|r|jj3�tjd�}|r|j5t6||�w|j5t8j:|�wxYw)Nr�ztest_logging-cqh-r@rrTrr��listenerr~r�bazzqueue not emptyrFr�)r~rr�)r#r}�config_queue_handlerr6r�rrrZr�r��assertIsNotNoner�r�r�r�r�r�sleeping_retryr`r��emptyr�r�rarYrr�r�r1r�)	rD�qspec�lspec�cdr5�qhr�r�rRs	         rH�do_queuehandler_configurationz,ConfigDictTest.do_queuehandler_configuration�s:��
�]�]�4�4�4�
5��
�F�$7�
8��+-��:��t��Z�(���,1�B�z�N�4� ��)���/4�B�z�N�4� ��,�
��	/����b�!��)�)�$�/�B����V�G�$;�$;�$=�>��t��M�� � ����-��K�K�����M�M�%� ��L�L����O�O�E�"��(�(��)=�)=�):�<��;�;�$�$�*�*�,���(�(��)=�)=�):�<�
�K�K���"�"�$��b�7�+�
-�q��v�v�x�*�*�,��
-����T�#8�9����� � �"��(�(��.�A����� 0�!�R�8�����	�	�2�.�
-�
-������ � �"��(�(��.�A����� 0�!�R�8�����	�	�2�.�s,�D6I/�1I/�<I#�I/�#I,�(I/�/A-Kc�0�t�}tdzdd�}tdzdddd�}dtdztdz||f}dtdz|tf}tj||�D]\}}|j||��dd	td
df}dd	td
df}tj||�D]a\}}|�|��|jt�5}|j||�ddd�tj�}	|j|	d
��cy#1swY�3xYw)Nz.CustomQueuerd)r��maxsizez.listenerMakerT)r�r�r�r�z.queueMakerz.CustomListenerrwrr~rz Unable to configure handler 'ah')r�rqr��	itertools�productr�rrr=r_rqr�rZ)
rD�q�dq�dl�qvalues�lvaluesr�r��ctxrs
          rH�test_config_queue_handlerz(ConfigDictTest.test_config_queue_handler�s?���M���^�+��
��
�-�-���%)�	
����M�1�8�n�3L�b�RS�T����$5�5�r�>�J��%�-�-�g�w�?�	=�L�E�5��.�.�u�e�<�	=���C��U�+����C��U�+��%�-�-�g�w�?�	F�L�E�5��}�����"�"�:�.�
A�#��2�2�5�%�@�
A��c�m�m�$�C����S�"D�E�
	F�
A�
A�s�D�D	c��dddddd�idddgd�id	�}tjd�}|j|j�|j	|�|j|j�|j	d
di�|j|j�|d=|j	|�|j|j�y)NrlF�consoler8r�)r�rrir�)r	r�r@r�r	r�)rrrWrr�rC)rDr�r�s   rH�
test_90195zConfigDictTest.test_90195s����(-��$�4����$�!*����
�� �"�"�3�'��������)����&�!�������)����9�a�.�)�������(��-�.����&�!�������)rjc���tjd�tjd�}ddd|jd�j�d�idgdd	�d
�}tj
j
|�y)N�_multiprocessing�multiprocessingrl�sinkr�spawn)rr�r8)r@r�r)r�
import_module�get_contextr�rr�r)rD�mpr�s   rH�test_111615zConfigDictTest.test_1116156sv���#�#�$6�7�
�
(�
(�):�
;����<��^�^�G�4�:�:�<���$�H� ��
��	���!�!�&�)rjr�)]rqrrrsr
r�rWr�rr�r�r$r(r�r�r�r�r�r.r�r�r�r�r;r�r>r?rCrFrIrMrQrXrr;rr[rzr�r�r�r�r�r�r�rr�r�r�r%r)r�r�r/r�r2r�r9r<r@rDrGrJrNrRrUrYr\rir�requires_working_socketrmrorxr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r	r�r�r�r�rtrjrHr�r�U	s���3� /� I� I��,�����9��
�
�1�%�"�.�	�
� �!��
��G�.���9��
�
�1�%�"�.�	�
�
�!�%�Y�!�
�
�i�
�+�G�8���9��
�
�1�%�"�.�	�
�
��'�!�
� �!��
�)�H�8���9��
�
�1�%�"�/�	�
�
�!�%�Y�!�
�
�i�
�+�G�8���9��
�
�1�%�"�.�	�
�
�!�%�Y�!�
�
�i�
�+�H�:���9��
�
�1�%�"�.�	�
�
�!�%�Y�!�
�
�i�
�+�H�8���9��
�
�1�/�"�.�	�
�
�!�%�Y�!�
�
�i�
�+�G�8���"7�7�?��
�
�1�%�"�.�	�
��%�Y�
�!�G�0�*�?��
 �-�/�?��
"�?��

� 2�%�"�.�	��{��

��%�Y�
�7�H�F���9��
�
�"�%5�5�%�"�.�	�
�
�!�%�Y�!�
�
�i�
�+�G�:���9��
�
�"�%5�5�%�"�.�.��
�
�!�%�Y�!�
�
�i�
�-�G�<���9��
�
�1�%�"�.�	�
�
�!�%�Y� �
�
�i�
�+�G�<�%*���9��
�
�1�%�"�.�	�
�"�%�Y�� �
�
�i�
�1�G�>�%)���9��
�
�1�%�"�.�	�
�"�%�Y�� �
�
�i�
�1�H�<���9��
�
�1�%�#�.�	�
�
�#�%�Y�!�
�
�h�
�+�G�6����)��
�
��&�!�
�
�H� ����&��
�
��&�!�
�
�H�"���9��
�
��*��
�
�1�%�"�.�$�I��
�
�!�$�I�!�
� �!��
�7�H�F���9��
�
�1�%�"�.�	�
�/��4�
�
�!�%�Y�!�
�
�i�
�3�H�B
��9��
�
�1�%�"�.�	�
�/��4�
�
�!�%�Y�!�
�
�i�
�1�H�>���9��
�
�1�%�"�.�	�
�/��4�
�
�!�%�Y�!�
�
�i�
�3�H�@���9��
�
�1�%�"�.� �"'��	�
� �!��
�'�H�8��;�*�N�;��
�
�1�%�"�.�	�
� �!��
�!�H�,*�'�+�+�*���%��.�%�%�w���

�
�1�&�"�.�	�
� �!��
�+�H�8��M��"�
�1� �0��:��0�&� ��


�
� �+�,�#��
�-�J�B���!6�6�>�!��
�
�0�$�!�,�	�
�
.� �$�I�#�0�
�#'�#�8��!�$9�9�>�!��
�
�0�$�!�,�	�
�
.� �$�I�#�0�
�#(�$�8��!�$8�8�>�!��
�
�0�$�!�,�	�
�
.� �$�I�#�0�
�#(�$�8�� �>�!��
�
�0�$�!�,�	�
�
.� �$�I�#�0�
�#&�"�8�� �N�*�I�6��
�
�0�$�!�,�	�
�
.� �$�I�#�0�
�#&�"�6��.��
9�!�F��	
����
���$(�&�&� &-�
&�F�G�G�F�&� 
&�3�F�&�< &�D+&�Z�&�(,�G�G�J�7�2:�?�
,�8%�W�$�$�&��'��(%�W�$�$�&�&�'�&�%�W�$�$�&�<,�'�<,�|J�
9�E�
E�
E�`�^�^�B�,B�>)�)�	)��&/�P1��0�0�2�F�3�F�8*�<*rjr�c��eZdZd�Zd�Zy)�ManagerTestc�j��g�G�fd�dtj�}tjd�}|jt|j
t�|j|�|jd�}|jd�tjd�|j�dg�y)Nc���eZdZd�fd�	Zy)�6ManagerTest.test_manager_loggerclass.<locals>.MyLoggerNc�(���j|�yr��r_)rDr�rr2�exc_info�extra�loggeds      �rH�_logz;ManagerTest.test_manager_loggerclass.<locals>.MyLogger._logOs����
�
�c�"rjrp)rqrrrsr�)r�s�rH�MyLoggerr�Ns���
#rjrr�zshould appear in loggedzshould not appear in logged)
r�Logger�Managerr=�	TypeError�setLoggerClassrrrr�rZ)rDr�manr�r�s    @rH�test_manager_loggerclassz$ManagerTest.test_manager_loggerclassKs������	#�w�~�~�	#��o�o�d�#�����)�S�%7�%7��=����8�$����v�&�����0�1����5�6�����";�!<�=rjc��tjd�}t�}|j|�|j	|j
|�yr�)rr�object�setLogRecordFactoryrZ�logRecordFactory)rDrrfs   rH�test_set_log_record_factoryz'ManagerTest.test_set_log_record_factory[s;���o�o�d�#���8������)�����-�-�x�8rjN)rqrrrsrrrtrjrHr�r�Js��>� 9rjr�c��eZdZd�Zd�Zy)�ChildLoggerTestc�v�tj�}tjd�}tjd�}|jd�}|jd�}|j|tjd��|j|tjd��|jd�}|jd�}|jd�}|j|tjd��|j|tjd��|j||�y)	N�abczdef.ghi�xyzzuvw.xyz�def�ghi�abc.defzabc.def.ghi)rr�getChildr�)rDr��l1�l2�c1�c2�c3s       rH�test_child_loggersz"ChildLoggerTest.test_child_loggersbs��������
�
�
�u�
%��
�
�
�y�
)��
�Z�Z��
��
�Z�Z�	�
"���
�
�b�'�+�+�E�2�3��
�
�b�'�+�+�I�6�7�
�[�[��
��
�[�[��
��
�[�[��
#���
�
�b�'�+�+�I�6�7��
�
�b�'�+�+�M�:�;��
�
�b�"�rjc���tj�}tjd�}tjd�}tjd�}tjd�}|j�}||h}|j|||z�|j	||�|j�}|j|h|�|j�}|jt�|�y)Nr~�foo.barzfoo.bar.baz.bozzr)rr�getChildrenrZ�assertNotInr)rDr�rr�l3�l4�kidsrfs        rH�test_get_childrenz!ChildLoggerTest.test_get_childrenqs��������
�
�
�u�
%��
�
�
�y�
)��
�
�
�1�
2��
�
�
�u�
%���}�}�����8������4�(�?�3�����X�&��~�~������"��t�$��~�~���������%rjN)rqrrrsrr"rtrjrHr
r
as��
�
&rjr
c��eZdZy)�DerivedLogRecordNr�rtrjrHr$r$�r�rjr$c��eZdZd�Zd�Zd�Zy)�LogRecordFactoryTestc��Gd�dtj�}tj|�|t�|_|jj|j
�tj�|_	y)Nc��eZdZd�Zd�Zy)�2LogRecordFactoryTest.setUp.<locals>.CheckingFilterc��||_yr�)rq)rDrqs  rHr�z;LogRecordFactoryTest.setUp.<locals>.CheckingFilter.__init__�s	����rjc�p�t|�}||jurd|�d|j��}t|��y)NzUnexpected LogRecord type z, expected T)r�rqr)rDr�r�rs    rHr�z9LogRecordFactoryTest.setUp.<locals>.CheckingFilter.filter�s5����L���D�H�H�$�IJ� �H�H�&�C�#�C�.�(�rjN)rqrrrsr�r�rtrjrH�CheckingFilterr)�s��
�
rjr,)
rr�rrIr$r�r1r��getLogRecordFactory�orig_factory)rDr,s  rHrIzLogRecordFactoryTest.setUp�sV��
	�W�^�^�
	�	���t��$�%5�6������"�"�4�;�;�/�#�7�7�9��rjc��|jj|j�tj	|�tj|j�yr�)r1r�r�rrSrr	r.rns rHrSzLogRecordFactoryTest.tearDown�s<�����%�%�d�k�k�2����$���#�#�D�$5�$5�6rjc��|jt|jj|j	��tjt�|jj|j	��|jdg�y)N)r�r}r~)
r=rr1r�rorr	r$r�rirns rH�test_logrecord_classz)LogRecordFactoryTest.test_logrecord_class�sn�����)�T�%5�%5�%=�%=��+�+�-�	/��#�#�$4�5������t�0�0�2�3����!�
�	rjN)rqrrrsrIrSr1rtrjrHr&r&�s��:�$7�
rjr&c�$�eZdZdZd�Zd�Zd�Zd�Zeje
ejd�d�d��Z
eje
ejd�d�d	��Zeje
ejd�d�d
��Zy)�QueueHandlerTestr�c��tj|�tjd�|_tj
j
|j�|_d|_t	jd�|_
d|j_|jjtj�|jj|j�y)NrJ�queF)rrIr�r�rr@�QueueHandler�que_hdlrrFr�
que_loggerrir7r�rBrns rHrIzQueueHandlerTest.setUp�s������t���[�[��_��
��(�(�5�5�d�j�j�A��
���	�!�+�+�E�2���$)����!���� � ����1����"�"�4�=�=�1rjc�b�|jj�tj|�yr�)r7rKrrSrns rHrSzQueueHandlerTest.tearDown�rkrjc��|jj|j��|jtj
|jj�|jj|j��|jtj
|jj�|j�}|jj|�|jj
�}|jt|tj��|j|j|jj�|j|j|j f|df�yr�)r8r�ror=r��Empty�
get_nowaitr�r�rCrrrrZrFrr2)rDrr�s   rH�test_queue_handlerz#QueueHandlerTest.test_queue_handler�s��������d�/�/�1�2����%�+�+�t�z�z�'<�'<�=������T�.�.�0�1����%�+�+�t�z�z�'<�'<�=����!��������$��z�z�$�$�&�����
�4��):�):�;�<�������D�O�O�$8�$8�9����$�(�(�D�I�I�.��d��<rjc��|j�}tjtj�}d}|j	|j
||��}tj|j�}|jj|�|jj|�|jj�}|j||j�|j||j �y)Nz {name} -> {levelname}: {message})rF�	levelnamer�)rorr�r�r rFr;r<r7r>r8r�r�r<rZrr�)rDrr?�log_format_str�
formatted_msgr��
log_records       rH�test_formattingz QueueHandlerTest.test_formatting�s������!���(�(����9�	�;��&�-�-�4�9�9�8A�3�.�P�
��%�%�d�o�o�6�	��
�
�"�"�9�-�������$��Z�Z�*�*�,�
�����
���7�����
�(:�(:�;rj�
QueueListenerz5logging.handlers.QueueListener required for this testc��ttj��}tjj|j|�}|j�	|jj|j��|jj|j��|jj|j��|j�|j|jtj d���|j|jtj"d���|j|jtj$d���|j'�ttj��}|j)tj$�tjj|j|d��}|j�	|jj|j��|jj|j��|jj|j��|j�|j+|jtj d���|j+|jtj"d���|j|jtj$d	���|j'�y#|j�wxYw#|j�wxYw)
Nr|)r�r�r~rT)r�r�r�r�)r
r�Matcherrr@rDr�r�r8r�ror�r�rrC�matchesr�r}r{rKr7rW)rDr�r�s   rH�test_queue_listenerz$QueueHandlerTest.test_queue_listener�s2���g�o�o�/�0���#�#�1�1�$�*�*�g�F������	��O�O�#�#�D�$5�$5�$7�8��O�O�!�!�$�"3�"3�"5�6��O�O�$�$�T�%6�%6�%8�9��M�M�O������������M�N��������
�
�s��K�L��������0@�0@�#��N�O��
�
���g�o�o�/�0������)�)�*��#�#�1�1�$�*�*�g�HL�2�N������	��O�O�#�#�D�$5�$5�$7�8��O�O�!�!�$�"3�"3�"5�6��O�O�$�$�T�%6�%6�%8�9��M�M�O����������#��N�O������������L�M��������0@�0@�#��N�O��
�
���-
�M�M�O��$
�M�M�O�s�A;L)�=A;L>�)L;�>Mc��tjj|j|j�}|j�	ddz|jj|j�d��|j�|j|jj�j�j!d�d�|j|jj�j�j!d�d�y#t$r8}|}|jj|j�|��Yd}~��d}~wwxYw)Nrlr�r�T��
stack_info�	Traceback�Stack)rr@rDr�r:r��ZeroDivisionErrorr8r�ror�rrZr6rXrr�)rDr�r(�excs    rH�&test_queue_listener_with_StreamHandlerz7QueueHandlerTest.test_queue_listener_with_StreamHandler�s���#�#�1�1�$�*�*�d�n�n�M������	I�
��E�	
�����d�/�/�1�d��C��
�
��������-�-�/�5�5�7�=�=�k�J�A�N�������-�-�/�5�5�7�=�=�g�F��J��
!�	I��C��O�O�%�%�d�&7�&7�&9�C�%�H�H��	I�s�D�	E�-E�Ec���|jj|j�|jj	|j
�tjj|j|j�}|j�|jjd�|j�|j|jj�j!�d�y)Nr�zque -> ERROR: error)r7r>r=r8rBr:rr@rDr�r�r�rrZr6rXr)rDr�s  rH�*test_queue_listener_with_multiple_handlersz;QueueHandlerTest.test_queue_listener_with_multiple_handlerss���	
�
�
�"�"�4�#6�#6�7����"�"�4�>�>�2��#�#�1�1�$�*�*�d�m�m�L�����������g�&��
�
��������-�-�/�5�5�7�9N�OrjN)rqrrrsrWrIrSr=rCr��
skipUnlessrDrr@rHrQrSrtrjrHr3r3�s���3��2� �
=�<��X�����!1�!1�?�C�P�R��R��B�X�����!1�!1�?�C�P�R�K�R�K��X�����!1�!1�?�C�P�R�	P�R�	Prjr3rD)�patchc���eZdZ	dZed��Zejejjd�d��Zejejjd�d��Zed��Z
d�Zd�Zy	)
�QueueListenerTest�c�>�	tjd|z�}|jtj�tjj|�}|j
|�tjj|�}|j�|jd�|jd�|jd�|jd�|jd�|j�|j|�|j�y)Nztest_logger_with_id_%s�one�two�three�four�five)
rrr7r8r@r6rBrDr�r�rrLrK)�	log_queuer_r�r�r�s     rH�
setup_and_logzQueueListenerTest.setup_and_logs���
�
�&�&�'?�%�'G�H�F��O�O�G�M�M�*��&�&�3�3�I�>�G����g�&��'�'�5�5�i�@�H��N�N���K�K����K�K����K�K�� ��K�K����K�K����M�M�O�� � ��)��M�M�OrjrVc��t|j�D];}tj�}|j	||j��d|����=|j
|jd|jzd�y�Nr�r
z&correct number of handled log messages)rx�repeatr�r�r`rrZ�
call_count�rD�mock_handlertr_s    rH�#test_handle_called_with_queue_queuez5QueueListenerTest.test_handle_called_with_queue_queue7sh���4�;�;�'�
H��!�K�K�M�	��"�"�9�����A�.F�G�
H�
���[�3�3�Q����_�E�
Grjc�f�tj�t|j�D][}t	j
�}|j
||j��d|���|j�|j��]|j|jd|jzd�yrb)r�*skip_if_broken_multiprocessing_synchronizerxrcr�r�r`rrKrrZrdres    rH� test_handle_called_with_mp_queuez2QueueListenerTest.test_handle_called_with_mp_queue?s���
�>�>�@��4�;�;�'�
(��+�1�1�3�	��"�"�9�����A�.F�G����!��%�%�'�	
(�

���[�3�3�Q����_�E�
Grjc#�jK�		|j����#tj$rgcYSwxYw�wr�)r<r�r;)r_s rH�get_all_from_queuez$QueueListenerTest.get_all_from_queueLs9����
��#�.�.�0�0����;�;�
��	�
�s�3��0�3�0�3c
�8�	tj�t|j�D]�}t	j
�}|j
||j��d|���t|j|��}|j�|j�gtjjjgg}|j!||d|D�cgc]*}t#|tj$�r|j&n|��,c}z���ycc}w)Nr�z&Found unexpected messages in queue: %s)rrirxrcr�r�r`r�listrlrKrrr@rD�	_sentinelr�rrr)rDrtr�r�rfr�s      rH�$test_no_messages_in_queue_after_stopz6QueueListenerTest.test_no_messages_in_queue_after_stopTs���
�
�>�>�@��4�;�;�'�
>��'�-�-�/���"�"�5�D�G�G�I�q�*A�B��T�4�4�U�;�<������
�!��!�!�#���!1�!1�!?�!?�!I�!I� J�K���
�
�e�X�F�5:�%<�01�/9��G�<M�<M�.N�Q�U�U�*+�&,�%<�=�>�
>��%<s�/Dc��tj�}tjj	|�}|j�|j
�|jt�5|j�ddd�y#1swYyxYwr�)
r�r�rr@rDr�rr=r_�	task_done)rDr_r�s   rH�test_calls_task_done_after_stopz1QueueListenerTest.test_calls_task_done_after_stoplse�����
�I��'�'�5�5�i�@�H��N�N���M�M�O��"�"�:�.�
&��#�#�%�
&�
&�
&�s�)B�BN)rqrrrsrc�staticmethodr`rUrrr@rDrgrjrlrprsrtrjrHrWrWs���	�
��	�	�
�	�.
����g�&�&�4�4�h�	?�	G�
@�	G�
����g�&�&�4�4�h�	?�
	G�
@�
	G�
�	�
�	�	>�0	&rjrWc��eZdZd�ZeZd�Zy)�UTCc��tSr�)�ZERO�rD�dts  rH�	utcoffsetz
UTC.utcoffsetzs���rjc��y)Nrvrtrys  rH�tznamez
UTC.tznames��rjN)rqrrrsr{�dstr}rtrjrHrvrvys����C�rjrvc��eZdZd�Zy)�AssertErrorMessagec��	|jdg|��i|��y#|$r%}|j|t|��Yd}~yd}~wwxYw)Nrt)r=rZrq)rDr�r�r2r3r(s      rH�assert_error_messagez'AssertErrorMessage.assert_error_message�sH��	.��D���b�2�4�2�6�2���	.����W�c�!�f�-�-��	.�s��A�>�AN)rqrrrsr�rtrjrHr�r��s��.rjr�c�P�eZdZd�Zd
d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
y)�
FormatterTestc	��dtjtjj	ddd�dddddd�|_d	d	d
ii|_y)Nzformatter.testrX�toz	dummy.extr�zMessage with %d %s)r��placeholders)rFr��pathname�linenor�r�rr2ri�)rr8r1rXr��common�variantsrns rHrIzFormatterTest.setUp�sP��$��]�]������V�T�;�?����'�'�	
���
��$��
��
rjNc��t|j�}|�|j|j|�t	j
|�Sr�)rr�rNr�rr�)rDrFr�s   rH�
get_recordzFormatterTest.get_record�s<���d�k�k�"�����M�M�$�-�-��-�.��$�$�V�,�,rjc�r�|j�}tjd�}|j|j	|�d�tjd�}|jt|j|�|j|j��tjd�}|j|j��tjd�}|j|j��tjd�}|j|j��y)Nz${%(message)s}z${Message with 2 placeholders}z
%(random)s�%(asctime)sz%(asctime)-15sz%(asctime)#15s�
r�rr;rZr r=r_rW�usesTimerC�rDr�r�s   rH�test_percentzFormatterTest.test_percent�s����O�O������.�/��������!��&F�G����l�+�����*�a�h�h��2��������&����m�,������
�
��%����.�/������
�
��%����.�/������
�
��%rjc��|j�}tjdd��}|j|j	|�d�tjdd��}|jt|j|�tjdd��}|j|j��tjdd��}|j|j��tjdd��}|j|j��tjd	d��}|j|j��y)
Nz
$%{message}%$r�r
�$%Message with 2 placeholders%$z{random}r�	{asctime}z{asctime!s:15}z{asctime:15}r�r�s   rH�test_braceszFormatterTest.test_braces�s����O�O������o�S�9��������!��&G�H����j��4�����*�a�h�h��2����k��5���������&����k��5������
�
��%����.�c�:������
�
��%����n�C�8������
�
��%rjc���|j�}tjdd��}|j|j	|�d�tjdd��}|j|j	|�d�tjdd��}|j|j	|�d�tjdd��}|jt|j|�|j|j��tjd	d��}|j|j��tjd
d��}|j|j��tjdd��}|j|j��tjdd��}|j|j��y)N�
${message}rr�zMessage with 2 placeholdersz$messagez$$%${message}%$$r�z	${random}z
${asctime}z$asctimez${asctime}--r�r�s   rH�test_dollarszFormatterTest.test_dollars�s^���O�O������l�#�6��������!��&C�D����j��4��������!��&C�D����0��<��������!��&G�H����k��5�����*�a�h�h��2��������&����l�#�6������
�
��%����j��4������
�
��%����l�#�6���������&����n�C�8������
�
��%rjc�h�tjd�}|j|jd�tjd�}|j|jd�tjd�}|j|jd�tjd�}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjd	d��}|j|jd	�tjd
d��}|j|jd
�tjdd��}|j|jd�tjdd��}|j|jd�tjd
d��}|j|jd
�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�tjdd��}|j|jd�|j	t
tjd�|j	t
tjd�|j	t
tjd�|j	t
tjd�|j	t
tjd�|j	t
tjd�|j	t
tjd�|j	t
tjd �|j	t
tjd!�|j
t
d"tjd#d��|j
t
d$tjd%d��|j
t
d&�|j	t
tjd'd��|j
t
d(tjd)d��|j
t
d*tjd+d��|j	t
tjd,d��|j	t
tjd-d��|j	t
tjd.d��|j	t
tjd/d��|j
t
d0tjd1d��|j
t
d2tjd3d��|j	t
tjd4d��|j	t
tjd5d��|j	t
tjd6d��|j	t
tjd7d��|j	t
tjd8d��|j	t
tjd9d��|j	t
tjd:d��|j	t
tjd;d��|j	t
tjd<d��|j
t
d=tjd>d��|j
t
d=tjd?d��|j
t
d=tjd@d��|j
t
d$tjdd��|j	t
tjd%d��|j
t
d$tjdAd��|j	t
tjdBd��y)CNzM%(levelname)-15s - %(message) 5s - %(process)03d - %(module) - %(asctime)*.3sz1%(asctime)*s - %(asctime)*.3s - %(process)-34.33oz%(process)#+027.23Xz
%(foo)#.*gz5$%{message}%$ - {asctime!a:15} - {customfield['key']}rr�z{process:.2f} - {custom.f:.4f}z{customfield!s:#<30}z{message!r}z{message!s}z{message!a}z{process!r:4.2}z8{process!s:<#30,.12f}- {custom:=+#30,.1d} - {module:^30}z{process!s:{w},.{p}}z{foo:12.{p}}z{foo:{w}.6}z{foo[0].bar[1].baz}z{foo[k1].bar[k2].baz}z{12[k1].bar[k2].baz}z${asctime} - $messagerz$bar $$z	$bar $$$$z%(asctime)Zz%(asctime)bz%(asctime)*z
%(asctime)*3sz%(asctime)_r�r�z
%(foo)#12.3*fz%(foo)0*.8*fz;invalid format: invalid field name/expression: 'name-thing'z{name-thing}zinvalid format: no fieldsr�zinvalid conversion: 'Z'z{asctime!s:#30,15f}z7invalid format: expected ':' after conversion specifierz{asctime!aa:15}z%invalid format: bad specifier: '.2ff'z{process:.2ff}z
{process:.2Z}z{process!s:<##30,12g}z{process!s:<#30#,12g}z{process!s:{{w}},{{p}}}z1invalid format: expected '}' before end of stringz{processz7invalid format: Single '}' encountered in format stringzprocess}z{{foo!r:4.2}z
{{foo!r:4.2}}z	{foo/bar}z{foo:{{w}}.{{p}}}}z{foo!X:{{w}}.{{p}}}z{foo!a:random}z{foo!a:ran{dom}z{foo!a:ran{d}om}z
{foo.!a:d}z$invalid format: bare '$' not allowedz$bar $$$zbar $zfoo $.r~z	${asctime)rr;rZ�_fmtr=r_r��rDr�s  rH�test_format_validatez"FormatterTest.test_format_validate�s���
���m�n��������!p�q����Q�R��������!T�U����3�4��������!6�7����l�+���������.�
���U�]`�a��������!X�Y����>�c�J��������!A�B����4�C�@��������!7�8����m�3�7���������/����m�3�7���������/����m�3�7���������/����/�s�;��������!2�3����X�`c�d��������![�\����4�C�@��������!7�8����n�C�8���������0����m�3�7���������/����3�3�?��������!6�7����5�S�A��������!8�9����4�C�@��������!7�8�
���5�S�A��������!8�9����i�s�3���������+����k��5���������-�	
���*�g�&7�&7��G����*�g�&7�&7��G����*�g�&7�&7��G����*�g�&7�&7��I����*�g�&7�&7��G����*�g�&7�&7��E����*�g�&7�&7��F����*�g�&7�&7��I����*�g�&7�&7��H�	
�!�!��I����~�S�	"�	
�	
�!�!��'����}�C�	"�	
�	
�!�!��%�	
�	
���*�g�&7�&7�9N�VY��Z��!�!��E����0��	"�	
�	
�!�!��3����/�s�	"�	
�
	
���*�g�&7�&7��PS��T����*�g�&7�&7�9P�X[��\����*�g�&7�&7�9P�X[��\����*�g�&7�&7�9R�Z]��^��!�!��?����z��	"�	
�
	
�!�!��E����z��	"�	
�
	
���*�g�&7�&7��s��S����*�g�&7�&7��PS��T����*�g�&7�&7��C��P����*�g�&7�&7�9M�UX��Y����*�g�&7�&7�9N�VY��Z����*�g�&7�&7�9I�QT��U����*�g�&7�&7�9J�RU��V����*�g�&7�&7�9K�SV��W����*�g�&7�&7��S��Q�	
�!�!��4����z��	"�	
�
	
�!�!��4����w�c�	"�	
�
	
�!�!��4����x�s�	"�	
�	
�!�!��'����{�#�	"�	
�
	
���*�g�&7�&7��c��R�	
�!�!��'����u�C�	"�	
�
	
���*�g�&7�&7��C��Prjc�b�gd�}gd�}t||�D�]\}}tj||ddi��}|j�}|j	|j|�d�|jd�}|j	|j|�d�tj||��}|j�}|j
t|j
|�tj||d	di��}|jd�}|j	|j|�d���y)
N)z%(custom)s %(message)sz{custom} {message}z$custom $message)�%rrr�Default)r
rz#Default Message with 2 placeholdersz 1234 Message with 2 placeholdersr�zNon-existing)r\rr;r�rZr r=r_)rD�fmts�stylesr�r
r�r�s       rH�test_defaults_parameterz%FormatterTest.test_defaults_parameterns��S�� ���d�F�+�	N�J�C���!�!�#�U�h�	�=R�S�A����!�A����Q�X�X�a�[�*O�P�����)�A����Q�X�X�a�[�*L�M��!�!�#�U�3�A����!�A����j�!�(�(�A�6��!�!�#�U�n�i�=X�Y�A�����)�A����Q�X�X�a�[�*L�M�	Nrjc�R�|jttjddd�y)N�x)r=r_rr;rns rH�test_invalid_stylez FormatterTest.test_invalid_style�s�����*�g�&7�&7��t�S�Irjc
��|j�}tjdddddddt�}tj|jd�j
��|_d|_tjd�}tj|_|j|j|�d	�|j|j|d
�d�|j|�|j|j d	�y)N��rw��r�r�{�%(asctime)s %(message)sz1993-04-21 08:03:00,123z%Y:%dz1993:21)r��datetime�utcry�mktime�
astimezone�	timetuple�created�msecsrr;�gmtime�	converterrZ�
formatTimer �asctime)rDr�rzr�s    rH�	test_timezFormatterTest.test_time�s����O�O���
�
�
�t�Q��A�q�!�Q��
<���K�K��
�
�d� 3� =� =� ?�@��	�������7�8���k�k���������a��*C�D�������a��1�9�=�	�����������$=�>rjc
�~�Gd�dtj�}|j�}tjddddddd	t�}tj|jd�j��|_	|�}t
j|_|j|j|�d
�y)Nc��eZdZdZdZy)�DFormatterTest.test_default_msec_format_none.<locals>.NoMsecFormatterNz%d/%m/%Y %H:%M:%S)rqrrrs�default_msec_format�default_time_formatrtrjrH�NoMsecFormatterr��s��"&��"5�rjr�r�rwr�r�r�rr�z21/04/1993 08:03:00)rr;r�r�r�ryr�r�r�r�r�r�rZr�)rDr�r�rzr�s     rH�test_default_msec_format_nonez+FormatterTest.test_default_msec_format_none�s���	6�g�/�/�	6�
�O�O���
�
�
�t�Q��A�q�!�S�#�
>���K�K��
�
�d� 3� =� =� ?�@��	�����k�k���������a��*?�@rjc��tjddd��}td�D]W}tjd�tj
dd|d	zzi�}|j
|�}|jd
|��Yy)Nz!{asctime}.{msecs:03.0f} {message}rr)r�r
ri�	g-C��6:?rz
Message %drlz.1000)rr;rxryr{r�r r)rDr�rtr�rhs     rH�test_issue_89047zFormatterTest.test_issue_89047�sr�����"E�S�Zm�n���t��	)�A��J�J�v���%�%�u�l�a�!�e�.D�&E�F�A������A����W�a�(�		)rjr�)rqrrrsrIr�r�r�r�r�r�r�r�r�r�rtrjrHr�r��s?��
�"-�
&�&� &�*TQ�lN�(J�?�
A�)rjr�c��eZdZd�Zd�Zy)�TestBufferingFormatterc��dt|�zS)Nz[(%d)�r[�rDrs  rH�formatHeaderz#TestBufferingFormatter.formatHeader������W��%�%rjc��dt|�zS)Nz(%d)]r�r�s  rH�formatFooterz#TestBufferingFormatter.formatFooter�r�rjN)rqrrrsr�r�rtrjrHr�r��s��&�&rjr�c��eZdZd�Zd�Zd�Zy)�BufferingFormatterTestc�j�tjddi�tjddi�g|_y)NrrZr[)rr�rrns rHrIzBufferingFormatterTest.setUp�s/���!�!�5�%�.�1��!�!�5�%�.�1�
��rjc���tj�}|jd|jg��|jd|j|j��y)Nr�onetwo)r�BufferingFormatterrZr rr�s  rH�test_defaultz#BufferingFormatterTest.test_default�sE���&�&�(������Q�X�X�b�\�*�����1�8�8�D�L�L�#9�:rjc��t�}|jd|j|j��t	j
d�}t|�}|jd|j|j��y)Nz[(2)onetwo(2)]z
<%(message)s>z[(2)<one><two>(2)])r�rZr rrr;)rDr��lfs   rH�test_customz"BufferingFormatterTest.test_custom�s`��"�$�����)�1�8�8�D�L�L�+A�B�
�
�
��
/��"�2�&�����-�q�x�x����/E�FrjN)rqrrrsrIr�r�rtrjrHr�r��s��
�;�
Grjr�c��eZdZd�Zy)�
ExceptionTestc�V�|j}t�}|j|�	td��#t	j
dd��YnxYw|j
|�|j�|jd}|j|jjd��|j|jjd��|j|jjd��|j|jjd	��y)
Nr��failedTrKrz#Traceback (most recent call last):
z!
RuntimeError: deliberate mistake�Stack (most recent call last):
z,logging.exception('failed', stack_info=True))r1�RecordingHandlerrBr�rr�rLrKrrC�exc_textrr\rL)rDr�rRs   rHrCzExceptionTest.test_formatting�s����������	���Q��	9��3�4�4��	9����h�4�8��	�����	���	�
�I�I�a�L������
�
�-�-�/>�?�	@�����
�
�+�+�-A�B�	C�������/�/�1>�?�	@�������-�-�/?�@�	As	�4�AN)rqrrrsrCrtrjrHr�r��s��Arjr�c��eZdZd�Zy)�LastResortTestc���|j}|j|j�tj}tj
}	t
j�5}|jd�|j|j�d�|jd�|j|j�d�ddd�dt_t
j�5}|jd�d}|j|j�|�ddd�t
j�5}|jd�|j|j�d�ddd�d|j_
dt_t
j�5}|jd�|j|j�d�ddd�|j|j�|t_|t_y#1swY��OxYw#1swY��xYw#1swY��xYw#1swY�axYw#|j|j�|t_|t_wxYw)NzThis should not appearrz
Final chance!zFinal chance!
z-No handlers could be found for logger "root"
F)r1rLr:r�
lastResortr�rr�r�rZrXr�r�emittedNoHandlerWarningrB)rDr��old_lastresort�old_raise_exceptionsr�rs      rH�test_last_resortzLastResortTest.test_last_resort�s����������4�>�>�*� �+�+��&�6�6��	;��(�(�*�
G�f��
�
�3�4�� � ����!2�B�7����_�-�� � ����!2�4E�F�	
G�"&�G���(�(�*�
9�f����_�-�F��� � ����!2�C�8�
9��(�(�*�
8�f����_�-�� � ����!2�B�7�
8�
49�D�L�L�0�&+�G�#��(�(�*�
8�f����_�-�� � ����!2�B�7�
8�
�O�O�D�N�N�+�!/�G��&:�G�#�7
G�
G��
9�
9��
8�
8��
8�
8��
�O�O�D�N�N�+�!/�G��&:�G�#�sm�	H?�A#H
�'H?�'4H�H?�72H'�)8H?�!2H3�H?�
H�H?�H$�H?�'H0�,H?�3H<�8H?�?3I2N)rqrrrsr�rtrjrHr�r��s��#;rjr�c��eZdZd�Zd�Zy)�FakeHandlerc
�N�dD] }t|||j|||���"y)N)r�rrKr�)�setattr�record_call)rD�
identifier�calledres    rHr�zFakeHandler.__init__s.��>�	P�F��D�&�$�"2�"2�:�v�v�"N�O�	Prjc��������fd�}|S)Nc�H���jdj����y)Nz{} - {})r_r )r�r��method_names���rH�innerz&FakeHandler.record_call.<locals>.inners����M�M�)�*�*�:�{�C�Drjrt)rDr�r�r�r�s ``` rHr�zFakeHandler.record_calls���	E��rjN)rqrrrsr�r�rtrjrHr�r��s
��P�rjr�c�$��eZdZ�fd�Zd�Z�xZS)r�c�:��tt|�
|i|��g|_yr�)r�r�r�r)rDr2r3r�s   �rHr�zRecordingHandler.__init__
s���
���.��?��?���rjc�<�	|jj|�yr�)rr_r�s  rHrVzRecordingHandler.handles��4������F�#rj)rqrrrsr�rVr�r�s@rHr�r�s
����$rjr�c�z��eZdZ	�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Z�xZS)�ShutdownTestc���tt|��g|_tj
}|j
ttd|�y)Nr�)r�r�rIr�rr�r�r�)rD�raise_exceptionsr�s  �rHrIzShutdownTest.setUps7���
�l�D�'�)����"�2�2�������*;�=M�Nrjc����fd�}|S)Nc������r�rt)r�s�rHr�z'ShutdownTest.raise_error.<locals>.inner"s
����'�Mrjrt)rDr�r�s ` rH�raise_errorzShutdownTest.raise_error!s
���	��rjc�T�td|j�}td|j�}td|j�}ttjj
|||g�}tjt|���gd�}|j||j�y)Nrrlr�rz)z2 - acquirez	2 - flushz	2 - closez2 - releasez1 - acquirez	1 - flushz	1 - closez1 - releasez0 - acquirez	0 - flushz	0 - close�0 - release)	r�r�r�rr|r}rrnrZ)rD�handler0�handler1�handler2r@rfs      rH�test_no_failurezShutdownTest.test_no_failure&s����q�$�+�+�.���q�$�+�+�.���q�$�+�+�.���w���*�*�X�x��,J�K�����T�(�^�4�L��	
����4�;�;�/rjc�$�td|j�}t|||j|��tj
j
|�g}t	jt|���|jd|jd�y)Nrrzr�rJ)
r�r�r�r�rr|r}rrnrZ)rDrer�r�r@s     rH�_test_with_failure_in_methodz)ShutdownTest._test_with_failure_in_method6sj���a����-������!1�!1�%�!8�9��O�O�'�'��0�1�����T�(�^�4��������B��8rjc�0�|jdt�y�Nr��rr^rns rH�test_with_ioerror_in_acquirez)ShutdownTest.test_with_ioerror_in_acquire?s���)�)�)�W�=rjc�0�|jdt�y�Nrrrns rH�test_with_ioerror_in_flushz'ShutdownTest.test_with_ioerror_in_flushB����)�)�'�7�;rjc�0�|jdt�y�NrKrrns rH�test_with_ioerror_in_closez'ShutdownTest.test_with_ioerror_in_closeEr
rjc�0�|jdt�yr�rr_rns rH�test_with_valueerror_in_acquirez,ShutdownTest.test_with_valueerror_in_acquireHs���)�)�)�Z�@rjc�0�|jdt�yrrrns rH�test_with_valueerror_in_flushz*ShutdownTest.test_with_valueerror_in_flushK����)�)�'�:�>rjc�0�|jdt�yrrrns rH�test_with_valueerror_in_closez*ShutdownTest.test_with_valueerror_in_closeNrrjc�F�dt_|jdt�y)NFr��rr�r�
IndexErrorrns rH�.test_with_other_error_in_acquire_without_raisez;ShutdownTest.test_with_other_error_in_acquire_without_raiseQs��"'����)�)�)�Z�@rjc�F�dt_|jdt�y)NFrrrns rH�,test_with_other_error_in_flush_without_raisez9ShutdownTest.test_with_other_error_in_flush_without_raiseU���"'����)�)�'�:�>rjc�F�dt_|jdt�y)NFrKrrns rH�,test_with_other_error_in_close_without_raisez9ShutdownTest.test_with_other_error_in_close_without_raiseYrrjc�f�dt_|jt|jdt�y)NTr��rr�r=rrrns rH�+test_with_other_error_in_acquire_with_raisez8ShutdownTest.test_with_other_error_in_acquire_with_raise]s'��"&������*�d�&G�&G�#�Z�	1rjc�f�dt_|jt|jdt�y)NTrr rns rH�)test_with_other_error_in_flush_with_raisez6ShutdownTest.test_with_other_error_in_flush_with_raiseb�'��"&������*�d�&G�&G�!�:�	/rjc�f�dt_|jt|jdt�y)NTrKr rns rH�)test_with_other_error_in_close_with_raisez6ShutdownTest.test_with_other_error_in_close_with_raisegr$rj)rqrrrsrIr�rrrr	r
rrrrrrr!r#r&r�r�s@rHr�r�sY���-�O��
0� 9�>�<�<�A�?�?�A�?�?�1�
/�
/rjr�c�d�eZdZ	d�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zy)�ModuleLevelMiscTestc���tjjj}|j	|d�|jtj|�tjd�|j	tjjjd�|j
ttjd�Gd�d�}|j
ttj|��tjd�tj�|j	tjjjtj�y)Nr�S�
doesnotexistsc��eZdZy)�;ModuleLevelMiscTest.test_disable.<locals>._NotAnIntOrStringNr�rtrjrH�_NotAnIntOrStringr-|���rjr.�WARN)
rr�rrOrZr�r=r_rr{)rD�old_disabler.s   rH�test_disablez ModuleLevelMiscTest.test_disableqs����l�l�*�*�2�2������a�(��������5������������-�-�5�5�r�:����*�g�o�o��G�	�	�	
���)�W�_�_�6G�6I�J������	����������-�-�5�5�w�7G�7G�HrjNc�4��g�tj|td�fd��t�}tjj|�t
t|�}|�||d|�n	|d|�|jt|j�d�|jd}|j|j�d|z�|�|nt
t|j��}|j|j|�|j�g�y)N�basicConfigc�*���j||f�Sr�r�)ri�kwr�s  �rH�<lambda>z/ModuleLevelMiscTest._test_log.<locals>.<lambda>�s���v�}�}�a��W�'=�rjztest me: %rrlr)
rrUrr�r�rBr-rZr[r�
getMessage�upperr�)rDrer��	recording�
log_methodr��expected_levelr�s       @rH�	_test_logzModuleLevelMiscTest._test_log�s�������
�
�d�G�]�=�	?�%�&�	������	�*��W�f�-�
����u�m�Y�7��}�i�0�����Y�.�.�/��3��"�"�1�%������*�*�,�m�i�.G�H�"'�"3����&�,�,�.�9Y���������8�	
�����$rjc�D�|jdtj�y�Nr�)r=rr}rns rH�test_logzModuleLevelMiscTest.test_log�s�����u�g�m�m�,rjc�&�|jd�y�Nr��r=rns rH�
test_debugzModuleLevelMiscTest.test_debug�������w�rjc�&�|jd�y�Nr�rCrns rH�	test_infozModuleLevelMiscTest.test_info�������v�rjc�&�|jd�y�Nr�rCrns rH�test_warningz ModuleLevelMiscTest.test_warning�������y�!rjc�&�|jd�y�Nr�rCrns rH�
test_errorzModuleLevelMiscTest.test_error�rErjc�&�|jd�y�Nr�rCrns rH�
test_criticalz!ModuleLevelMiscTest.test_critical�������z�"rjc��|jttjt�Gd�dtj
�}tj|�|j
tj�|�tjtj
�|j
tj�tj
�y)Nc��eZdZy)�;ModuleLevelMiscTest.test_set_logger_class.<locals>.MyLoggerNr�rtrjrHrrW�r/rjr)r=rrrrrrZ�getLoggerClass)rDrs  rH�test_set_logger_classz)ModuleLevelMiscTest.test_set_logger_class�s������)�W�%;�%;�V�D�	�w�~�~�	�	���x�(�����/�/�1�8�<����w�~�~�.�����/�/�1�7�>�>�Brjc����g�G�fd�dtj��}tj|�tjd�}|j	�dg�tj�}tj|�}|j|�	|jtj�|jd�|j	|j�j�d�|jd�|jd�|jtj �|jd�|j	|j�d�|j#|�|j%�tjtj&�y#|j#|�|j%�tjtj&�wxYw)Nc�<���eZdZdejf��fd�	Z�xZS)�@ModuleLevelMiscTest.test_subclass_logger_cache.<locals>.MyLoggerrc�H��t�|�||��jd�y)N�initialized)r�r�r_)rDrFr�r�r�s   ��rHr�zIModuleLevelMiscTest.test_subclass_logger_cache.<locals>.MyLogger.__init__�s����� ��u�-����}�-rj)rqrrrsrr�r�r�)r�r�s@�rHrr\�s���$.�g�n�n�
.�
.rjr�just_some_loggerr^�hellorr)rrXrrrZr4r5r9rBr7r8r�rXr�truncater�r�rLrKr)rDrr�r6rRr�s     @rH�test_subclass_logger_cachez.ModuleLevelMiscTest.test_subclass_logger_cache�sZ�����	.�w�-�-�/�	.�
	���x�(��"�"�#5�6������=�/�2�������!�!�&�)�����!��	3��O�O�G�M�M�*��L�L��!����V�_�_�.�4�4�6��@��O�O�A���K�K��N��O�O�G�L�L�)��L�L��!����V�_�_�.��3�� � ��#�
�G�G�I��"�"�7�>�>�2��
� � ��#�
�G�G�I��"�"�7�>�>�2�s�CF0�0AG6c��tjd�}td|�\}}}|j�}|j	d|�|j	d|�y)Na*
            import logging

            class A:
                def __del__(self):
                    try:
                        raise ValueError("some error")
                    except Exception:
                        logging.exception("exception in __del__")

            a = A()
        �-czexception in __del__zValueError: some error)r�r�rr�r��rD�code�rc�out�errs     rH�test_logging_at_shutdownz,ModuleLevelMiscTest.test_logging_at_shutdown�sR����� �
��(��d�3���C���j�j�l���
�
�,�c�2��
�
�.��4rjc�N�tj}|jtj|�t	j
d|�d��}t
d|�t|d��5}|j|j�j�d�ddd�y#1swYyxYw)Na�
            import builtins
            import logging

            class A:
                def __del__(self):
                    logging.error("log in __del__")

            # basicConfig() opens the file, but logging.shutdown() closes
            # it at Python exit. When A.__del__() is called,
            # FileHandler._open() must be called again to re-open the file.
            logging.basicConfig(filename=z�, encoding="utf-8")

            a = A()

            # Simulate the Python finalization which removes the builtin
            # open() function.
            del builtins.open
        rdrFr�zERROR:root:log in __del__)r�TESTFNr�rRr�r�rr�rZrar�)rDrTrf�fps    rH�test_logging_at_shutdown_openz1ModuleLevelMiscTest.test_logging_at_shutdown_open�s����#�#�����	�(�(�(�3����$*�+3��6	� �
��&	��t�$�
�(�W�
-�	N�����R�W�W�Y�-�-�/�1L�M�	N�	N�	N�s�#/B�B$c��tjd�}td|�\}}}|j�}|j	d|�|j|d�y)Nz�
            import logging

            def rec():
                logging.error("foo")
                rec()

            rec()
        rdz#Cannot recover from stack overflow.rl)r�r�rr�rrZres     rH�test_recursion_errorz(ModuleLevelMiscTest.test_recursion_errorsU����� �
��-�T�4�8���C���j�j�l�����>��D�����Q�rjc��tj�}|jtj|�|j	tj|�tj�}|j	||�|j||�yr�)r�getLevelNamesMappingrZr(�assertIsNot)rD�mapping�new_mappings   rH�test_get_level_names_mappingz0ModuleLevelMiscTest.test_get_level_names_mappingsj���.�.�0������-�-�w�7�����-�-�w�7��2�2�4������+�.�����+�.rjr�)rqrrrsr2r=r@rDrHrLrPrSrYrbrjrnrprvrtrjrHr(r(msN��3�I�.%�0-� ��"� �#�
C�3�>5�&N�> � /rjr(c��eZdZd�Zd�Zed
d��Zd�Zd�Zd�Z	e
j�d��Ze
j�d	��Z
y)�
LogRecordTestc���tji�}t|�}|j|j	d��|j|jd��y)Nz<LogRecord: �>)rr�rqrCrr\)rDr�rhs   rH�test_str_repzLogRecordTest.test_str_rep)sD���!�!�"�%����F��������^�4�5�����
�
�3��(rjc�|�t�}tj�}|j|�ddi}tjd|�|j|jdj|�|j|jdjd�|j|�|j�y)N�less�morezless is %(less)srzless is more)r�rrrBr�r�rr2rZr�rLrK)rDrRr�r�s    rH�
test_dict_argzLogRecordTest.test_dict_arg/s�����������	���Q��
�f������*�A�.��
�
�a�i�i��l�'�'��+�������1��-�-�~�>�	�����	���	rjNc���tj}|t_	ddl}|j�j}tj
dd|��i�}t
jtjdd�5tj
dd|��i�}ddd�||jjd�}|t_|r|j|�y|S#1swY�DxYw#|t_wxYw)Nrr�msg1_r��msg2_)�processName�r1.processName�r2.processName)r�logMultiprocessingr��current_processrFr�r�	swap_itemrP�modulesr�rb)	r�r�r0�prev_logMultiprocessingr�rF�r1�r2�resultss	         rH�_extract_logrecord_process_namez-LogRecordTest._extract_logrecord_process_name:s���")�"<�"<��%7��"�	A�(��%�%�'�,�,�D��&�&���s�e�}�'=�>�B��"�"�3�;�;�0A�4�H�
C��*�*�E�U�3�%�=�+A�B��
C�)-�)+���)+����G�
*A�G�&���I�I�g���N�
C�
C��*A�G�&�s$�AC$�:C�"C$�C!�C$�$
C1c��tj�dtjv}	|j	t
jd�d}tji�}|j	|jd�|jd|�}|j	d|d�|j	d|d�|j	d|d�ddl
}|j�\}}|j|jd	||f�
�}|j�|j�}|jd|d�|j	|d|d�|j	d|d�|j!�|rddl
}yy#|rddl
}wwxYw)Nr�T�MainProcessrlr�r�r�rr�r�)rrirPr�rZrr�r�r�r�r��Pipe�Processr�r*�assertNotEqualr�)	rD�multiprocessing_imported�LOG_MULTI_PROCESSINGr�r�r��parent_conn�
child_connr�s	         rH�test_multiprocessingz"LogRecordTest.test_multiprocessingSsz���:�:�<�#4����#C� � 	'����W�7�7��>�#'� ��%�%�b�)�A����Q�]�]�M�:��:�:�1�>R�S�G����]�G�M�,B�C����]�G�4D�,E�F����]�G�4D�,E�F�
#�&:�o�&:�&:�&<�#�K��'��'�'��;�;��-�z�;��A�
�G�G�I�!�&�&�(�G����
�w�}�/E�F����W�]�3�W�=M�5N�O����]�G�4D�,E�F�
�F�F�H�(�&�(��'�&�(�s�EE?�?	Fc��|j}|j}tji�}||j�||j
�||j�||j�||j�tj}tj}tj}tj}	dt_	dt_
dt_dt_tji�}||j�||j
�||j�||j�||j�|t_	|t_
|t_|t_y#|t_	|t_
|t_|t_wxYw)NF)
r�r�rr�r��
threadName�processr��taskName�
logThreads�logProcessesr��logAsyncioTasks)rD�NONE�NOT_NONEr��log_threads�
log_processes�log_multiprocessing�log_asyncio_taskss        rH�
test_optionalzLogRecordTest.test_optionalxsE��� � ���'�'���!�!�"�%�����������������������Q�Z�Z���(�(���,�,�
�%�8�8��#�3�3��	8�!&�G��#(�G� �).�G�&�&+�G�#��%�%�b�)�A�����N����������O�����������!,�G��#0�G� �)<�G�&�&7�G�#��"-�G��#0�G� �)<�G�&�&7�G�#�s
�	BF�.F?c��ZK�tji�}||j�y�wr�)rr�r�)rD�	assertionr�s   rH�_make_record_asyncz LogRecordTest._make_record_async�s"�����!�!�"�%���!�*�*��s�)+c�~�	|j}tj�5}dt_|j||j��dt_|j||j��ddd�tjd�y#1swY�xYw#tjd�wxYw)NTF)	r��asyncio�Runnerrr��runr�r��set_event_loop_policy�rD�make_record�runners   rH�#test_taskName_with_asyncio_importedz1LogRecordTest.test_taskName_with_asyncio_imported�s���	0��1�1�K����!�
;�V�*.��'��
�
�;�t�';�';�<�=�*/��'��
�
�;�t�'8�'8�9�:�	
;�
�)�)�$�/�

;�
;��
�)�)�$�/�s#� B%�AB�;B%�B"�B%�%B<c���	|j}tj�5}tjt
jdd�5dt_|j||j��dt_|j||j��ddd�ddd�tjd�y#1swY�'xYw#1swY�+xYw#tjd�wxYw)Nr�TF)r�r�r�rr�rPr�rr�r�r�r�r�s   rH�&test_taskName_without_asyncio_importedz4LogRecordTest.test_taskName_without_asyncio_imported�s���	0��1�1�K����!�
;�V�W�->�->�s�{�{�I�W[�-\�
;�*.��'��
�
�;�t�'8�'8�9�:�*/��'��
�
�;�t�'8�'8�9�:�	
;�
;�
�)�)�$�/�

;�
;��
;�
;��
�)�)�$�/�s;� C�&C�AC�!C�)C�C	�C�C�C�C6r�)rqrrrsr{rrtr�r�r�r�rr�r�r�rtrjrHrxrx(so��)�	�����0#'�J8�@�%�W�$�$�&�	0�'�	0�%�W�$�$�&�	0�'�	0rjrxc����eZdZ	�fd�Z�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zej0�d��Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Z �xZ!S)�BasicConfigTestc�|��tt|��tjj
|_tjj�|_tjdd|_
tjj|_|j|j�gtj_yr�)r�r�rIrr�r@r"r#r$r%r&r�r3r��cleanupr�s �rHrIzBasicConfigTest.setUp�sy���
�o�t�*�,����-�-��
�%�/�/�4�4�6���")�"6�"6�q�"9���&-�l�l�&8�&8��#�������%� "����rjc����tjjddD]1}tjj|�|j	��3t
t|��yr�)rr�r@rLrKr�r�rS)rDrRr�s  �rHrSzBasicConfigTest.tearDown�sK������&�&�q�)�	�A��L�L�&�&�q�)�
�G�G�I�	�	�o�t�-�/rjc�h�ttjd|j�tjj�tjj
|j�|jtjddtjj|j�y)Nr@)r�rr�r@r"rMrNr$r&r%r7r3rns rHr�zBasicConfigTest.cleanup�sp������j�$�-�-�8������!���� � ��!4�!4�5�"&�"9�"9����Q�������d�9�9�:rjc���tj�|jttjj
�d�tjj
d}|j
|tj�|j|jtj�|j}|j|jjtj�|j|j �|j
|jtj"�|jtjj$|j&�y)Nrlr)rr4rZr[r�r@r�r9r6rPr�r�r~r��BASIC_FORMATr�r�PercentStyler�r3)rDr�r�s   rH�test_no_kwargszBasicConfigTest.test_no_kwargs�s�������	
����W�\�\�2�2�3�Q�7��,�,�'�'��*�����g�w�'<�'<�=����������4��%�%�	�����)�)�.�.��0D�0D�E����)�+�+�,����i�.�.��0D�0D�E�	
������+�+�T�-H�-H�Irjc�d�tj�5}tjtj
d��tjd�tj
jd�|j|j�j�d�ddd�y#1swYyxYw)Nr�r6r
�Log an errorr�ERROR:root:Log an error�rr�rr4rPr�r�r�rZrXrr,s  rH�test_strformatstylez#BasicConfigTest.test_strformatstyle��x��
�
$�
$�
&�	+�&����s�z�z��=��M�M�.�)��J�J�O�O�A�����V�_�_�.�4�4�6�)�
+�		+�	+�	+���BB&�&B/c�d�tj�5}tjtj
d��tjd�tj
jd�|j|j�j�d�ddd�y#1swYyxYw)Nrr�r�rr�r�r,s  rH�test_stringtemplatestylez(BasicConfigTest.test_stringtemplatestyle�r�r�c�X�d�}tjdd��|jttjj
�d�tjj
d}|j
|tj�tjddd��}|j|jj|jj�|j|jj|jj�|j|||d�y)	Nc�n�|j�|j�tj|�yr�r��r�h2r5s   rHr�z.BasicConfigTest.test_filename.<locals>.cleanup�����H�H�J��H�H�J��I�I�b�Mrj�test.logrF)rTrHrlrrir�)rr4rZr[r�r@r�rlr6�moderFr��rDr�r�rfs    rH�
test_filenamezBasicConfigTest.test_filename�s���	�
	���Z�'�B�����W�\�\�2�2�3�Q�7��,�,�'�'��*�����g�w�':�':�;��&�&�z�3��I��������,�,�h�o�o�.B�.B�C�������,�,�h�o�o�.B�.B�C������(�J�?rjc�:�d�}tjdd��tjjd}tjdd�}|j|jj|jj�|j|||d�y)Nc�n�|j�|j�tj|�yr�r�r�s   rHr�z.BasicConfigTest.test_filemode.<locals>.cleanupr�rjr��wb�rT�filemoder)	rr4r�r@rlrZr6r�r�r�s    rH�
test_filemodezBasicConfigTest.test_filemodesu��	�
	���Z�$�?��,�,�'�'��*���&�&�z�4�8��������,�,�h�o�o�.B�.B�C������(�J�?rjc��tj�}|j|j�t	j
|��|j
ttjj�d�tjjd}|j|tj�|j
|j|�y)Nr�rlr)
r4r5r�rKrr4rZr[r�r@r�r9r6)rDr6r�s   rH�test_streamzBasicConfigTest.test_streams��������������%����6�*�����W�\�\�2�2�3�Q�7��,�,�'�'��*�����g�w�'<�'<�=��������0rjc���tjd��tjjdj}|j|jjd�y)Nz%(asctime)s - %(message)s)r r)rr4r�r@r�rZr~r��rDr�s  rH�test_formatzBasicConfigTest.test_formatsH�����#>�?��L�L�)�)�!�,�6�6�	�����)�)�.�.�0K�Lrjc��tjd��tjjdj}|j|jd�y)Nr)rr)rr4r�r@r�rZrr�s  rH�test_datefmtzBasicConfigTest.test_datefmt#s@�����E�*��L�L�)�)�!�,�6�6�	�����*�*�E�2rjc���tjd��tjjdj}|j|jtj�y)Nrr�r)rr4r�r@r�r�r~rr�s  rH�
test_stylezBasicConfigTest.test_style)sF�����#�&��L�L�)�)�!�,�6�6�	����i�.�.��0K�0K�Lrjc��tjj}|jtjj|�tj
d��|j
tjjd�tj
d��|j
tjjd�y)N�9)r��:)rr�r�r�r7r4rZ)rD�	old_levels  rH�
test_levelzBasicConfigTest.test_level/sy���L�L�&�&�	�������-�-�y�9����"�%�������+�+�R�0����"�%�������+�+�R�0rjc��|j}tj�g}tj}|t
tjd|��|t
tjd|��|t
tj||��|t
tjtj��tjdd��y)Nr�)rTr6)rTr@)r6r@)�loglevelrir�)r=rr9rPr�r_r4r�)rDr=r@r6s    rH�test_incompatiblez!BasicConfigTest.test_incompatible9s����(�(���)�)�+�,�������Z��!4�!4�z�=C�	E��Z��!4�!4�z�?G�	I��Z��!4�!4�V�?G�	I�	�Z��!4�!4�w�|�|�L����T�C�8rjc�B�tj�tjtj�tj�g}tj�}|dj|�tj|��|j|dtjjd�|j|dtjjd�|j|dtjjd�|j|dj�|j|dj�|j|dj|�|j|dj|dj�y)Nr�)r@rrl)rr9rPr�r;r>r4r�r�r@r�r�)rDr@r�s   rH�
test_handlerszBasicConfigTest.test_handlersHs0���!�!�#��!�!�#�*�*�-��!�!�#�
��

�������� � ��#����X�.��
�
�h�q�k�7�<�<�#8�#8��#;�<��
�
�h�q�k�7�<�<�#8�#8��#;�<��
�
�h�q�k�7�<�<�#8�#8��#;�<����X�a�[�2�2�3����X�a�[�2�2�3��
�
�h�q�k�+�+�Q�/��
�
�h�q�k�+�+�X�a�[�-B�-B�Crjc���tj�}tj�}tj|�g}tj|�g}tjtj
|��tjd�tjd�tjd�|jttjj�d�tjtj|d��tjd�tjd�tjd�|jttjj�d�|j|j�j�d�|j|j�j�d	�y)
Nr�r�r�r�rlT)r�r@�forcezWARNING:root:warnz WARNING:root:warn
INFO:root:info)r4r5rr9r4r�r�r�r�rZr[r�r@r�rXr)rD�
old_string_io�
new_string_io�old_handlers�new_handlerss     rH�
test_forcezBasicConfigTest.test_forceYs;�����
�
����
�
��-�-�m�<�=���-�-�m�<�=�����'�/�/�L�I���������V���
�
�g������W�\�\�2�2�3�Q�7����'�,�,��"&�	(���������V���
�
�g������W�\�\�2�2�3�Q�7�����/�/�1�7�7�9�,�	.�����/�/�1�7�7�9�<�	>rjc��	d}tjd|ddtj��|jt	tj
j�d�tj
jd}|j|tj�|j|j|�tjd�|j�tdd�	�5}|j�j�}ddd�tj d�|jd�y#1swY�1xYw#j�tdd�	�5}|j�j�}ddd�n#1swYnxYwtj d�|jd�wxYw)
NrFr�r��%(message)s�rTrH�errorsr r�rlr�.The Øresund Bridge joins Copenhagen to Malmör��rr4r8rZr[r�r@r�rlrHr�rKr�rarr1r��rDrHr�r�r�s     rH�
test_encodingzBasicConfigTest.test_encodingnsU��	O��H�����h�'/�'4�G�M�M�
K�
���S����!6�!6�7��;��l�l�+�+�A�.�G��!�!�'�7�+>�+>�?����W�-�-�x�8��M�M�J�K��M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(��I�I�j�!����T�M�
O�
(�
(��
�M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(�
(�
(���I�I�j�!����T�M�
O��0�CE�*D9�9E�F?�#F�	F?�F�/F?c��	d}tjd|ddtj��|jt	tj
j�d�tj
jd}|j|tj�|j|j|�tjd�|j�tdd	�
�5}|j�j�}ddd�tj d�|jd�y#1swY�1xYw#j�tdd	�
�5}|j�j�}ddd�n#1swYnxYwtj d�|jd�wxYw)Nrr��ignorer�r�rlrr�rFr�z*The resund Bridge joins Copenhagen to Malmr�r�s     rH�test_encoding_errorsz$BasicConfigTest.test_encoding_errors�sO��	Q��H�����h�'/�'4�G�M�M�
K�
���S����!6�!6�7��;��l�l�+�+�A�.�G��!�!�'�7�+>�+>�?����W�-�-�x�8��M�M�J�K��M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(��I�I�j�!����T�#O�P�
(�
(��
�M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(�
(�
(���I�I�j�!����T�#O�P�r�c��	d}tjd|dtj��|jt	tj
j�d�tj
jd}|j|tj�|j|j|�|j|jd�tjd�|j�tdd	�
�5}|j�j�}ddd�t!j"d�|jd�y#1swY�1xYw#j�tdd	�
�5}|j�j�}ddd�n#1swYnxYwt!j"d�|jd�wxYw)Nrr�r�)rTrHr r�rlr�backslashreplaceu<😂: ☃️: The Øresund Bridge joins Copenhagen to MalmörFr�zL\U0001f602: \u2603\ufe0f: The \xd8resund Bridge joins Copenhagen to Malm\xf6)rr4r8rZr[r�r@r�rlrHr�r�rKr�rarr1r�r�s     rH�test_encoding_errors_defaultz,BasicConfigTest.test_encoding_errors_default�sm��	K��H�����h�'4�G�M�M�
K�
���S����!6�!6�7��;��l�l�+�+�A�.�G��!�!�'�7�+>�+>�?����W�-�-�x�8����W�^�^�-?�@��M�M�X�Y��M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(��I�I�j�!����T�$J�
K�
(�
(��
�M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(�
(�
(���I�I�j�!����T�$J�
K�s0�C&E �E�E� G�>F&�	G�&F/�+/Gc�$��	d}tjd|ddtj��|jt	tj
j�d�tj
jd}|j|tj�|j|j|�|j|j�g��fd�}||_tjd�|j��|jd	�d�|j!�t#dd
��5}|j%�j'�}ddd�t)j*d�|jd�y#1swY�1xYw#j!�t#dd
��5}|j%�j'�}ddd�n#1swYnxYwt)j*d�|jd�wxYw)
Nrr�r�r�rlrc�^���jttj���yr�)r_rqrPr�)r�r�s �rH�dummy_handle_errorzEBasicConfigTest.test_encoding_errors_none.<locals>.dummy_handle_error�s������s�3�=�=�?�3�4rjr�z:'ascii' codec can't encode character '\xd8' in position 4:rFr�r)rr4r8rZr[r�r@r�rlrHr�r�r�r�rCr�rKr�rarr1r�)rDrHr�rr�r�r�s      @rH�test_encoding_errors_nonez)BasicConfigTest.test_encoding_errors_none�s����	(��H�����h�'+�'4�G�M�M�
K�
���S����!6�!6�7��;��l�l�+�+�A�.�G��!�!�'�7�+>�+>�?����W�-�-�x�8����g�n�n�-��G�
5�#5�G���M�M�J�K��O�O�G�$��M�M�=�>E�a�j�
J�
�M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(��I�I�j�!����T�3�'�	
(�
(��
�M�M�O��j�7�3�
(�q��v�v�x�~�~�'��
(�
(�
(���I�I�j�!����T�3�'�s0�DF�:F	�	F�H�3G�	H�G$� /Hc��d�}d}tdd�}|jtj|�	d}t	j
|d|tjd��|jttjj�d�tjjd	}|j|tj�tjd
��5}d
t_|j!|��ddd�t#|d��5}|j%�j'�}ddd�|j)d
�tj*d�|r|j-�yy#1swY�xxYw#1swY�PxYw#tj*d�|r|j-�wwxYw)Nc��6K�tjd�y�w)Nzhello world)rr�rtrjrHrBz5BasicConfigTest.test_log_taskName.<locals>.log_record�s�����O�O�M�*�s�r�ztest-logging-taskname-rFr�z%(taskName)s - %(message)s)rTr�rHr�r rlrT)r�r�zTask-\d+ - hello world)r6r�r1r�rr4r�rZr[r�r@r�rlr�r�r�r�r�rar�assertRegexr�rK)rDrBr��log_filenamerHr�r�r�s        rH�test_log_taskNamez!BasicConfigTest.test_log_taskName�sa��	+���%�f�.F�G������	�	�<�0�	 ��H�����h�)1����'C�
E�
���S����!6�!6�7��;��l�l�+�+�A�.�G��!�!�'�7�+>�+>�?����d�+�
)�v�*.��'��
�
�:�<�(�
)��l�W�5�
(���v�v�x�~�~�'��
(����T�#<�=��)�)�$�/���
�
���
)�
)��
(�
(��
�)�)�$�/���
�
���s<�B0F�#"E<�F�F�9F�<F�F�F�
F�*F>c������g�tj����fd�}tj�td|�t	t|�}|�
||d�n|d��j�difg�y)Nc�����tjj}tjjd��j	tjj|��j||f�y)N�d)rr�r�r7r�r_)rir6r�r��old_basic_configrDs   ���rH�my_basic_configz2BasicConfigTest._test_log.<locals>.my_basic_config�sR��������*�*�I��L�L�!�!�#�&��O�O�G�L�L�1�1�9�=��M�M�1�b�'�"rjr4ztest mert)rr4rrUr-rZ)rDrer�rr;r�r
s`    @@rHr=zBasicConfigTest._test_log�si�����"�.�.��	#�	�
�
�d�G�]�O�D��W�f�-�
����u�i�(��y�!�	
����2�r�(��,rjc�D�|jdtj�yr?)r=rr�rns rHr@zBasicConfigTest.test_log�s�����u�g�o�o�.rjc�&�|jd�yrBrCrns rHrDzBasicConfigTest.test_debugrErjc�&�|jd�yrGrCrns rHrHzBasicConfigTest.test_inforIrjc�&�|jd�yrKrCrns rHrLzBasicConfigTest.test_warningrMrjc�&�|jd�yrOrCrns rHrPzBasicConfigTest.test_error
rErjc�&�|jd�yrRrCrns rHrSzBasicConfigTest.test_critical
rTrjr�)"rqrrrsrIrSr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�r	r=r@rDrHrLrPrSr�r�s@rHr�r��s����-�#�0�;�J�(+�+�@�$@�1�M�3�M�1�
9�D�">�*O�(Q�&K�((�@%�W�$�$�&� �'� �:-�./� ��"� �#rjr�c�B��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	�xZ
S)�LoggerAdapterTestc�D���tt|��tjdd�t�|_tj|_|jj|j�|j|jj|j�|j|jj��fd�}|j|�|jtj�tj|jd��|_y)Nc�,���tjddyr�)rr%)�old_handler_lists�rHr�z(LoggerAdapterTest.setUp.<locals>.cleanups���&6�G� � ��#rj�r�r�)r�rrIrr%r�r:r�r�rBr�rLrKrr��adapter)rDr�rr�s  @�rHrIzLoggerAdapterTest.setUps����
���,�.�"�/�/��2��)�+����l�l��������t�~�~�.�������1�1�4�>�>�B�������,�,�-�	7�	
���� �����(�(�)��,�,�D�K�K�t�L��rjc�f�d}d}	ddz|j	t|jj�d�|jjd}|j	|jtj�|j	|j|�|j	|j|jf�|j	|j|j||jf�y#t$r3}|}|jj||j�Yd}~�� d}~wwxYw�Nztesting exception: %rrlr)rOrr�r:rZr[rr�rr}rr2r�r��
__traceback__�rDrrPr(r�s     rH�test_exceptionz LoggerAdapterTest.test_exception#s���%����	8�
��E�
	
����T�^�^�3�3�4�a�8����'�'��*�����������7�������S�)�������t�~�~�&7�8��������-�-��c�.?�.?�@�	B��!�	8��C��L�L�"�"�3����7�7��	8���C4�4	D0�=(D+�+D0c�p�	ddz|jjd��|jt	|j
j�d�|j
jd}|j|j|j||jf�y#t$r}|}Yd}~��d}~wwxYw)Nrlrz
exc_info testrJ)
rOrr�rZr[r:rr�r�r)rDr(rPr�s    rH�test_exception_excinfoz(LoggerAdapterTest.test_exception_excinfo4s���	�
��E�	
��������=�����T�^�^�3�3�4�a�8����'�'��*���������-�-��c�.?�.?�@�	B��!�	��C��	�s�B � 	B5�)B0�0B5c��d}|jj||j�|jt	|jj
�d�|jj
d}|j|jtj�|j|j|�|j|j|jf�y)Nzcritical test! %rrlr)rr�r:rZr[rr�rr{rr2)rDrr�s   rHrSzLoggerAdapterTest.test_criticalAs���!�������c�4�>�>�2�����T�^�^�3�3�4�a�8����'�'��*���������)9�)9�:�������S�)�������t�~�~�&7�8rjc�b�|jjjj}d|jjj_|j	t
|jjjd|�|j
|jjd��y)N�!rO� )rr�rrOr�r�rW�isEnabledFor�rDr1s  rH�test_is_enabled_forz%LoggerAdapterTest.test_is_enabled_forKsw���l�l�)�)�1�1�9�9��.0������#�#�+��������!4�!4�!<�!<�i�#�	%�������2�2�2�6�7rjc�f�|j|jj��|jjD]}|jj|��|j
|jj��|j
|jj��yr�)rCrr?r�r@rLrWr�s  rH�test_has_handlersz#LoggerAdapterTest.test_has_handlersRs~��������0�0�2�3��{�{�+�+�	/�G��K�K�%�%�g�.�	/�	
������0�0�2�3�������1�1�3�4rjc���Gd�dtj�}d}||jd��}||d��}d|_|j	t|�t|��|j
tj||j�|j	t|jj�d�|jjd}|j	|jtj�|j	|jd|���|j	|j|jf�|j}|j|j|�|j|jj|�t!�}	||_|j|j|�|j|j|�|j|jj|�||_|j|j|�|j|j|�|j|jj|�y#||_wxYw)	Nc��eZdZdZd�Zy)�.LoggerAdapterTest.test_nested.<locals>.Adapter�Adapterc�(�|j�d|��|fSr��r�)rDrr3s   rHr�z6LoggerAdapterTest.test_nested.<locals>.Adapter.process_s���+�+��a��u�-�v�5�5rjN)rqrrrsr�r�rtrjrHr0r/\s���F�
6rjr0zAdapters can be nested, yo.r�AdapterAdapterrlrzAdapter AdapterAdapter )rr�r�r�rZr�r�r{r:r[rr�rr2rr�r)rDr0rr�adapter_adapterr��orig_manager�temp_managers        rH�test_nestedzLoggerAdapterTest.test_nested[s���	6�g�+�+�	6�,������D�9��!���=��!1�������g���_�(=�>����G�,�,�c�4�>�>�B�����T�^�^�3�3�4�a�8����'�'��*���������)9�)9�:�������'>�s�e�%D�E�������t�~�~�&7�8�&�.�.���
�
�g�o�o�|�4��
�
�d�k�k�)�)�<�8��x��	3�&2�O�#��M�M�/�1�1�<�@��M�M�'�/�/�<�8��M�M�$�+�+�-�-�|�<�&2�O�#��
�
�o�-�-�|�<��
�
�g�o�o�|�4��
�
�d�k�k�)�)�<�8��'3�O�#�s
�!A%I,�,	I5)rqrrrsrIr r#rSr*r,r7r�r�s@rHrrs)���M�"B�"B�9�8�5�9rjrc�~��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Z�xZS)�
LoggerTestc���tt|��t�|_tjd��|_|jj|j�|j|jj|j�|j|jj�|jt
j�y)N�blah�rF)
r�r9rIr�r:rrr�rBr�rLrKrr�s �rHrIzLoggerTest.setUps����
�j�$�%�'�)�+����n�n�&�1��������t�~�~�.�������1�1�4�>�>�B�������,�,�-�����(�(�)rjc��|jtd|jjd�|jtd|jjd�y)Nz,Level not an integer or a valid string: Nonez.Level not an integer or a valid string: (0, 0))rr)r�rr�r7rns rH�test_set_invalid_levelz!LoggerTest.test_set_invalid_level�sJ���!�!��E��K�K� � �$�	(�	
�!�!��G��K�K� � �&�	*rjc�f�d}d}	ddz|j	t|jj�d�|jjd}|j	|jtj�|j	|j|�|j	|j|jf�|j	|j|j||jf�y#t$r3}|}|jj||j�Yd}~�� d}~wwxYwr)rOr�r�r:rZr[rr�rr}rr2r�r�rrs     rHr zLoggerTest.test_exception�s���%����	7�
��E�
	
����T�^�^�3�3�4�a�8����'�'��*�����������7�������S�)�������t�~�~�&7�8��������-�-��c�.?�.?�@�	B��!�	7��C��K�K�!�!�#�t�~�~�6�6��	7�r!c��tjtdd�5|jt|j
jdd�ddd�y#1swYyxYw)Nr�Tr��test message)r�	swap_attrrr=rr�r�rns rH�!test_log_invalid_level_with_raisez,LoggerTest.test_log_invalid_level_with_raise�sJ��
�
�
�w�(9�4�
@�	P����i������$��O�	P�	P�	P�s�-A�Ac��tjtdd�5|jj	dd�ddd�y#1swYyxYw)Nr�Fr�rA)rrBrr�r�rns rH�test_log_invalid_level_no_raisez*LoggerTest.test_log_invalid_level_no_raise�s<��
�
�
�w�(9�5�
A�	2��K�K�O�O�D�.�1�	2�	2�	2�s�A�Ac����g�tj|tjd�fd��|jjd��|j
t��d�|j
d�d�y)N�print_stackc�B���j|j��Sr�)r_rX)r�r�r�s  �rHr7z=LoggerTest.test_find_caller_with_stack_info.<locals>.<lambda>�s���f�m�m�D�M�M�O�&D�rjTrKrlr�r)rrUr�	tracebackr��
findCallerrZr[)rDr�s @rH� test_find_caller_with_stack_infoz+LoggerTest.test_find_caller_with_stack_info�sd������
�
�d�G�-�-�}�D�	F�	
�����$��/�����V��a�(����;�V�A�Y�Grjc������d�|jj���fd���fd���fd�}|jj}|�|j	|dj
d�|dj}�dz
�|�|j	|dj
d�|j|dj|�|dj}�dz
�|�|j	|dj
d�|j|dj|�|dj}tj�}|j|j�tj�|�|j	|dj
d�|j|j�|jj��dz
�|�|j	|dj
d	�|j|dj|�y)
Nrlc����d���y)Nr�)�
stacklevelrt)�	the_level�triggers��rH�	innermostz>LoggerTest.test_find_caller_with_stacklevel.<locals>.innermost�s
����F�y�1rjc�����yr�rt)rQs�rHr�z:LoggerTest.test_find_caller_with_stacklevel.<locals>.inner�s����Krjc�����yr�rt)r�s�rH�outerz:LoggerTest.test_find_caller_with_stacklevel.<locals>.outer�s����GrjrJrQr�rT� test_find_caller_with_stacklevel)r�r�r:rrZr�r�r�rrrBrL)	rDrTrr�r1r�rQrOrPs	     @@@@rHrUz+LoggerTest.test_find_caller_with_stacklevel�s�����	��+�+�%�%��	2�	�	��.�.�(�(��
��������-�-�{�;����#�#���Q��	�
��������-�-�w�7����7�2�;�-�-�v�6����#�#���Q��	�
��������-�-�w�7����7�2�;�-�-�v�6����#�#���'�'�)�����t�~�~�.��/�/��
��������-�-�w�7��!�!�$�.�.�1��+�+�%�%���Q��	�
��������-�-�/Q�R����7�2�;�-�-�v�6rjc�(�d}d}dx}x}x}x}x}x}}	tj|||||||||	�	}
dt|
jj	��zD]:}|di}|jt|jj|||||||||	���<y)N�	my record�
)r�r��
some value�r��sinfo)	r�_logRecordFactoryr_�__dict__�keysr=r�r��
makeRecord)
rDrFr�r5�lnorr2r�r�r[�rvr�r�s
             rH�%test_make_record_with_extra_overwritez0LoggerTest.test_make_record_with_extra_overwrite�s�������:>�>��>�S�>�3�>��>��>�4�%�
�
&�
&�t�U�B��S�$�'/��u�>��*�E�"�+�+�2B�2B�2D�,E�E�	8�C��,�'�E����h����(>�(>��e� �#�s�D�(�$)��
�
8�	8rjc��d}d}dx}x}x}x}x}x}}	ddi}
|jj||||||||
|	��	}|jd|j�y)NrWrX�	valid_keyrYrZ)r�r_r�r])rDrFr�r5r`rr2r�r�r[r�r�s            rH�(test_make_record_with_extra_no_overwritez3LoggerTest.test_make_record_with_extra_no_overwrite�sx������:>�>��>�S�>�3�>��>��>�4�%��l�+�����'�'��e�R��c�4�(0��U�(�L���
�
�k�6�?�?�3rjc��|j|jj��|jjD]}|jj	|��|j|jj��yr�)rCr�r?r@rLrWr�s  rHr,zLoggerTest.test_has_handlers�sa��������/�/�1�2��{�{�+�+�	/�G��K�K�%�%�g�.�	/�������0�0�2�3rjc�z�tjd�}d|_|j|j	��y)Nz
blah.childF)rrrirWr?)rD�child_loggers  rH�test_has_handlers_no_propagatez)LoggerTest.test_has_handlers_no_propagate�s1���(�(��6��!&�������1�1�3�4rjc�&�|jjj}d|jj_|jt|jjd|�|j|jj
d��y)N�rO�)r�rrOr�r�rWr(r)s  rHr*zLoggerTest.test_is_enabled_for�sb���k�k�)�)�1�1��&(������#��������!4�!4�i��M�������1�1�"�5�6rjc��|jj}|jjj}d|j_d|jj_|j	t
|jd|�|j	t
|jjd|�|j
|jjd��y)NTr�rrOrl)r�rrrOr�r�rWr()rD�old_disabledr1s   rH�#test_is_enabled_for_disabled_loggerz.LoggerTest.test_is_enabled_for_disabled_loggers����{�{�+�+���k�k�)�)�1�1��#�����&(������#��������j�,�G��������!4�!4�i��M�������1�1�"�5�6rjc��tj�}|j|tj�|j|tjd��|j|tjd��|j|tjd��|j|tjd�j�|j|tjd�j�|j|tjd�j�|j|tjd��|j|tjd�j�y)Nrr�r~r�)rrr�r�rrs)rDr�s  rH�test_root_logger_aliasesz#LoggerTest.test_root_logger_aliasess��� � �"���
�
�d�G�L�L�)��
�
�d�G�-�-�d�3�4��
�
�d�G�-�-�b�1�2��
�
�d�G�-�-�f�5�6��
�
�d�G�-�-�e�4�9�9�:��
�
�d�G�-�-�i�8�=�=�>��
�
�d�G�-�-�e�4�;�;�<�����w�0�0��6�7�����w�0�0��;�B�B�Crjc��|jttjt�|jttjd�y)Nsfoo)r=rrr�anyrns rH�test_invalid_nameszLoggerTest.test_invalid_namess2�����)�W�%6�%6��<����)�W�%6�%6��?rjc��ttjdz�D][}dD]T}tj|�}tj
||�}tj|�}|j||��V�]y)Nrl)rr�r~rzbaz.bar)rxr-�HIGHEST_PROTOCOLrrrlr.r�)rD�protorFr�rh�	unpickleds      rH�
test_picklingzLoggerTest.test_picklingsk���6�2�2�Q�6�7�	1�E�A�
1�� �*�*�4�0���L�L���/��"�L�L��O�	��
�
�i��0�	
1�	1rjc�n
�|j}tjd�}tjd�}|jtj�|j|j
�tj�|j|ji�|j|jtj��|j|jtj��|j|jtjdtjdi�|j|ji�|j|jtj��|j|ji�|j|jtj��|j|jtjdi�|jtj�|j|j
�tj�|j|ji�|j|jtj��|jtj�|j|j
�tj�|j|ji�|j|ji�|j|ji�|j|jtj��|j|jtj��|j|jtj��|j|jtj��|j|jtj��tj�|j|j
�tj�|j|ji�|j|ji�|j|ji�|j|jtj��|j|jtj��|j|jtj��y)NrrTF)r1rrr7r}rZr2�_cacherCr(rWr8r{r�rO)rDr�r/r0s    rH�test_cachingzLoggerTest.test_caching'sz�������#�#�E�*���#�#�I�.��	
�
�
�g�m�m�$�����2�2�4�g�m�m�D��������,�	
����,�,�W�]�]�;�<�����-�-�g�m�m�<�=�������'�-�-��w�}�}�e�)T�U�������b�)�����,�,�W�]�]�;�<�	
������b�)�����)�)�'�-�-�8�9�������w�}�}�d�&;�<�	����)�)�*�����2�2�4�g�6F�6F�G��������,�	
����-�-�g�m�m�<�=�	������(�����2�2�4�g�6F�6F�G��������,��������,�������b�)�	
����-�-�g�m�m�<�=�����,�,�W�-=�-=�>�?�����-�-�g�m�m�<�=�����,�,�W�-=�-=�>�?�����)�)�'�-�-�8�9�	��������2�2�4�g�6F�6F�G��������,��������,�������b�)�	
����-�-�g�.>�.>�?�@�����-�-�g�.>�.>�?�@�����*�*�7�+;�+;�<�=rj)rqrrrsrIr>r rCrErKrUrbrer,rir*rorrrurzr}r�r�s@rHr9r9}s^���*�*�B�"P�2�H�%7�N8�4�4�5�
7�
7�D�@�1�6>rjr9c�&�eZdZ	d�Zd�Zd�Zd�Zy)�BaseFileTestc�^�tj|�tdd�|_g|_y)Nr�ztest_logging-2-)rrIr6r5�rmfilesrns rHrIzBaseFileTest.setUpcs$�����t�� ��):�;�����rjc�
�|jD]}tj|��tjj	|j
�rtj|j
�tj|�yr�)r�r1rRrXrYr5rrS)rDr5s  rHrSzBaseFileTest.tearDownhsR���,�,�	�B��I�I�b�M�	�
�7�7�>�>�$�'�'�"��I�I�d�g�g�����$�rjc��	|jtjj|�d|z��|jj|�y)NzLog file %r does not exist�r)rCr1rXrYr�r_)rDrTs  rH�
assertLogFilezBaseFileTest.assertLogFileos@��A���������x�0�8�8�C�	�	E������H�%rjc
�r�tjdtjdd|j�ddd�S)Nrsr�rl)rrr8rorns rH�next_reczBaseFileTest.next_recus5��� � ��g�m�m�S�!�!%�!2�!2�!4�d�D�$�H�	HrjN)rqrrrsrIrSr�r�rtrjrHrr`s��7��
 �&�Hrjrc��eZdZd�Zd�Zy)�FileHandlerTestc�:�tj|j�tj|jdd��}|j|j�|jtjj|j��|jtji��|j|j�|jtjj|j��|j�y)NrFTrG)r1rRr5rrlr�r6rWrXrYrVr�r�rCrK)rD�fhs  rH�
test_delayzFileHandlerTest.test_delayzs���
�	�	�$�'�'��
�
 �
 ����7�$�
G�����"�)�)�$������������0�1�
�	�	�'�'�'��+�,����R�Y�Y�'���������t�w�w�/�0�
���
rjc��tj|j�tj|jdd��}|jtjd��|j|j��|j�|j|j��t|j�5}|j|j�j�d�ddd�y#1swYyxYw)NrFrh)rHr�r�r|)r1rRr5rrlr>r;r?r�rKr�rZrar)rDr�rms   rH�%test_emit_after_closing_in_write_modez5FileHandlerTest.test_emit_after_closing_in_write_mode�s���
�	�	�$�'�'��
�
 �
 ����7��
E��
����)�)�-�8�9�
����
�
�� �
���
�
����
�
�� �
�$�'�'�]�	5�b����R�W�W�Y�_�_�.��4�	5�	5�	5�s�	/D�D
N)rqrrrsr�r�rtrjrHr�r�ys���	5rjr�c��eZdZejejd�d��Zd�Zd�Z	d�Z
d�Zej�d��Z
y)	�RotatingFileHandlerTest�WASI does not have /dev/null.c��tjj|jdd��}|j	|jd��|j
�tjjtjdd��}|j	|j|j���|j
�y)NrFr�rH�maxBytesrl)
rr@rmr5rW�shouldRolloverrKr1�devnullr��rD�rhs  rH�test_should_not_rolloverz0RotatingFileHandlerTest.test_should_not_rollover�s����
�
�
1�
1����'�A�2�7������*�*�4�0�1�
���
��
�
�
1�
1��
�
�W�q�2�:������*�*�4�=�=�?�;�<�
���
rjc���tjj|jdd��}|j	|j|j
���|j�y)NrFrlr�)rr@rmr5rCr�r�rKr�s  rH�test_should_rolloverz,RotatingFileHandlerTest.test_should_rollover�sJ��
�
�
�
1�
1�$�'�'�G�VW�
1�
X������)�)�$�-�-�/�:�;�
���
rjc���tjj|jd��}|j	|j��|j
|j�|j�y)NrFr�)rr@rmr5r?r�r�rKr�s  rH�test_file_createdz)RotatingFileHandlerTest.test_file_created�sP���
�
�
1�
1�$�'�'�G�
1�
L��
����
�
�� ����4�7�7�#�
���
rjc��d�}tjj|jddd��}||_|j|j
��|j|j�|j|j
��|j||jdz��|j|j
��|j||jdz��|jtjj||jdz���|j�y)	Nc��|dzS�N�.testrtr<s rH�namerz>RotatingFileHandlerTest.test_rollover_filenames.<locals>.namer�s���'�>�!rjrFr�rl�rH�backupCountr��.1�.2�.3)
rr@rmr5r�r?r�r�rWr1rXrYrK)rDr�r�s   rH�test_rollover_filenamesz/RotatingFileHandlerTest.test_rollover_filenames�s���	"�
�
�
�
1�
1��G�G�g�1�q�2�B�����
����
�
�� ����4�7�7�#�
����
�
�� ����5����4��0�1�
����
�
�� ����5����4��0�1����������d�g�g��n�(=�>�?�
���
rjc��Gd�dtjj�}||jddd��}|j	|j|j�|jdz�|j
|j��|j|j�|j
|j��|j|j|jdz�d	z�|jtjj|j|jdz���|j�y)
Nc��eZdZd�Zd�Zy)�ZRotatingFileHandlerTest.test_namer_rotator_inheritance.<locals>.HandlerWithNamerAndRotatorc��|dzSr�rt)rDrFs  rHr�z`RotatingFileHandlerTest.test_namer_rotator_inheritance.<locals>.HandlerWithNamerAndRotator.namer�s���g�~�%rjc�v�tjj|�rtj||dz�yy)N�.rotated)r1rXrYr�)rD�source�dests   rH�rotatorzbRotatingFileHandlerTest.test_namer_rotator_inheritance.<locals>.HandlerWithNamerAndRotator.rotator�s*���7�7�>�>�&�)��J�J�v�t�j�'8�9�*rjN)rqrrrsr�r�rtrjrH�HandlerWithNamerAndRotatorr��s��
&�
:rjr�rFr�rlr�r�r�r�)rr@rmr5rZr�r?r�r�rWr1rXrYrK)rDr�r�s   rH�test_namer_rotator_inheritancez6RotatingFileHandlerTest.test_namer_rotator_inheritance�s���	:��)9�)9�)M�)M�	:�(��G�G�g�1�q�B��������$�'�'�*�D�G�G�g�,=�>�
����
�
�� ����4�7�7�#�
����
�
�� ����2�8�8�D�G�G�d�N�3�j�@�A���������������4��(@�A�B�
���
rjc��d�}d�}tjj|jddd��}||_||_|j
�}|j|�|j|j�|j
�}|j|�||jdz�}|j|�tj}t|d�5}|j�}	tj|	�}
|j|
j!d	�|j"|z�ddd�|j|j
��||jd
z�}|j|�t|d�5}|j�}	tj|	�}
|j|
j!d	�|j"|z�ddd�|j|j
��||jd
z�}t|d�5}|j�}	tj|	�}
|j|
j!d	�|j"|z�ddd�|j%tj&j)||jdz���|j+�y#1swY���xYw#1swY��xYw#1swY�uxYw)Nc��|dzS)Nz.gzrtr<s rHr�z3RotatingFileHandlerTest.test_rotator.<locals>.namer�s���%�<�rjc� �t|d�5}|j�}tj|d�}t|d�5}|j	|�ddd�ddd�tj|�y#1swY�'xYw#1swY�+xYw)N�rbrpr�)r�ra�zlib�compressr�r1r�)r�r��sfr��
compressed�dfs      rHr�z5RotatingFileHandlerTest.test_rotator.<locals>.rotator�sy���f�d�#�
)�r��w�w�y��!�]�]�4��3�
��$��%�)���H�H�Z�(�)�
)�

�I�I�f��)�)��
)�
)�s#�3B�A8�B�8B	�=B�B
rFr�rlr�r�r�rr�r�)rr@rmr5r�r�r�r?r�r1�linesepr�rar��
decompressrZr�rrWrXrYrK)rDr�r�r��m1�m2r5�newliner�r�r�s           rH�test_rotatorz$RotatingFileHandlerTest.test_rotator�sV��	 �	��
�
�
1�
1��G�G�g�1�q�2�B����
����
�]�]�_��
��������4�7�7�#�
�]�]�_��
�����
�4�7�7�T�>�
"�����2���*�*��
�"�d�^�	E�q�����J��?�?�:�.�D����T�[�[��1�2�6�6�G�3C�D�	E�	����
�
�� �
�4�7�7�T�>�
"�����2��
�"�d�^�	E�q�����J��?�?�:�.�D����T�[�[��1�2�6�6�G�3C�D�	E�	����
�
�� �
�4�7�7�T�>�
"��
�"�d�^�	E�q�����J��?�?�:�.�D����T�[�[��1�2�6�6�G�3C�D�	E�	
���������d�g�g��n�(=�>�?�
���
�%	E�	E��	E�	E��	E�	E�s'�!AK�AK%�*AK2�K"�%K/�2K;N)rqrrrsr�r�r�is_wasir�r�r�r�r��
requires_zlibr�rtrjrHr�r��sZ���X�_�_�W�_�_�&E�F��G���
�
��&�W����*��*rjr�c�p�eZdZejejd�d��Zd�Zd�Z	d�Z
d�Zd�Zy)	�TimedRotatingFileHandlerTestr�c��tjjtjddd��}tjd�tjddi�}|j|j|��|j�y)N�SrFrl�rHr�皙�����?rztesting - device file)rr@rnr1r�ryr{r�rWr�rK)rDr�r�s   rHr�z5TimedRotatingFileHandlerTest.test_should_not_rollover�sp���
�
�
6�
6��
�
�C�'�q�7�B���
�
�3���!�!�5�*A�"B�C������*�*�1�-�.�
���
rjc��tjj|jddd��}tjd�}|j|�tjddi�}|j|�|j|j�tjd�tjdd	i�}|j|�|j�d
}tjj�}d}t|�D]w}|tj|��z
}	|j|	j!d
�z}
t"j$j'|
�}|s�\|j(j+|
�nd|z}|�st"j$j-|j�\}}
t#j.|�D�
cgc]}
|
j1|
�s�|
��}}
t3d|j!d�zt4j6��t3d|zt4j6��|D]^}
t3d|
z�t"j$j9||
�}t;|d�5}t3|j=��ddd��`|j?||��ycc}
w#1swY��xYw)Nr�rFrlr�r�rztesting - initialr�ztesting - after delayFi,��secondsz.%Y-%m-%d_%H-%M-%Sz,No rotated files found, went back %d secondsz
Test time: %sz%Y-%m-%d %H-%M-%S�r�zThe only matching files are: %szContents of %s:r�r�) rr@rnr5r;r>r�r?r�ryr{rKr�r=rx�	timedelta�strftimer1rXrYr�r_r��listdirrr�rPr�r�r�rarC)rDr�r�r�r��foundr=�GO_BACK�secs�prevr5r�dnr��filesrX�tfs                 rH�
test_rolloverz*TimedRotatingFileHandlerTest.test_rollovers5��
�
�
�
6�
6�����w�A�7�?����� 9�:��
�����
�
"�
"�E�+>�#?�
@��
��������4�7�7�#��
�
�3��
�
"�
"�E�+B�#C�
D��
�����
���
������#�#�%�����'�N�	�D���+�+�D�9�9�D����4�=�=�)=�>�>�B��G�G�N�N�2�&�E�����#�#�B�'��
	�=�w�F����W�W�]�]�4�7�7�+�F�B�� "�
�
�2��C�1�!�,�,�r�2B�Q�C�E�C��/�C�L�L�1D�$E�E�C�J�J�W��3�e�;�#�*�*�M��
%���'�!�+�,��w�w�|�|�B��*���$��_�%���"�'�'�)�$�%�%�
%�
	
����3��'��D�%�%�s�J5�-J5�=J:�:K	c�T�|j}|ttjj|j
ddd��|ttjj|j
ddd��|ttjj|j
ddd��y)N�XrFTrG�W�W7)r=r_rr@rnr5)rDr=s  rH�test_invalidz)TimedRotatingFileHandlerTest.test_invalid1s���(�(���Z��!1�!1�!J�!J��W�W�c�G�4�	A��Z��!1�!1�!J�!J��W�W�c�G�4�	A��Z��!1�!1�!J�!J��W�W�d�W�D�	Brjc	��d}tjddd�}tjj	|j
ddddd|��}	|j
|�}|j||dz�|j
|d	z�}|j||d
z�|j�y#|j�wxYw)Nr�rF�MIDNIGHTrlT�rH�when�intervalr�r��atTime��жi@�)	r�ryrr@rnr5�computeRolloverrZrK)rD�currentTimer�r�res     rH�"test_compute_rollover_daily_attimez?TimedRotatingFileHandlerTest.test_compute_rollover_daily_attime:s��������r�1�a�(��
�
�
�
6�
6��G�G�g�J��PQ��V�7�%��	��'�'��4�F����V�[�<�%?�@��'�'��l�(B�C�F����V�[�<�%?�@��H�H�J��B�H�H�J�s
�AB+�+B=c
�V�ttj��}||dzz
}tjddd�}tj|�j}td�D�]*}tjj|jdd|zddd|�	�}	||kDr	d|z
|z}n||z
}|dz}|d
z
}||z
}|j|�}||k7r2tdtjz�tdt�z�|j||�||k(r|d
z
}|j|dz�}||k7r2tdtjz�tdt�z�|j||�|j���-y#|j�wxYw)N�Qr�r�rFzW%drlTr�r�zfailed in timezone: %dzlocal vars: %si�:	r�)rrryr�r��tm_wdayrxrr@rnr5r�r��timezone�localsrZrK)	rDr��todayr��wday�dayr�rfres	         rH�#test_compute_rollover_weekly_attimez@TimedRotatingFileHandlerTest.test_compute_rollover_weekly_attimeJs����$�)�)�+�&���k�E�1�1�����r�1�a�(���{�{�5�!�)�)����8�	�C��!�!�:�:����'����a�UV���;�)�B�
��#�:�!"�D��3��H� #�d�
�H��L�(���L�(���E�!���+�+�E�2���X�%��2�T�]�]�B�C��*�V�X�5�6�� � ���2��$�;�� 0�0�H��+�+�E�L�,@�A���X�%��2�T�]�]�B�C��*�V�X�5�6�� � ���2����
�?	��>���
�s
�C#F�F(c��tjd��}|jtj|�g}t
j
j
�}td�D];}|j|jd��|tjd��z
}�=d}g}g}|D]�}tjj|d|z�}	tjj!|	d	dd
d��}
|j|
�|j#d
�r|D]}|j|�d|������d�|
_|D]}|j|�d|�d�����|D]8}tjj||�}	t'|	d�5}
	ddd��:t)|�D�]#\}}||}
|
j+�}|j-t/|�d�|j#d
�rOd|z}	|D]D}tjj1|�\}}|j3|j#|	���F��|D]�}tjj1|�\}}|j3|j5d��|j3|j#|dz�xr|t/|�dzj7������&y#1swY��xxYw)Nrr2rdz%Y-%m-%d_%H-%M-%Sr
r�)�a.bza.b.czd.ezd.e.fz%s.logrhr�T)r�r�r�rIr�z.log.c�,�|jdd�dzS)Nr�r)r�r<s rHr7zKTimedRotatingFileHandlerTest.test_compute_files_to_delete.<locals>.<lambda>�s��T�\�\�&�"�-E��-N�rjr�r�r�r�z%s.log.r�)r/�mkdtempr��shutil�rmtreer�r=rxr_r�r�r1rXr�rr@rnrr�r��	enumerate�getFilesToDeleterZr[r�rCr\�isdigit)rD�wd�timesrzrt�prefixesr��rotatorsr�r�r�r�r5r��
candidatesr�r�s                 rH�test_compute_files_to_deletez9TimedRotatingFileHandlerTest.test_compute_files_to_deleters���
�
�
�_�
5������
�
�r�*���
�
�
�
"�
"�
$���r��	0�A��L�L����%8�9�:��(�$�$�Q�/�/�B�	0�4�������
	<�F������R��F�!2�3�A��&�&�?�?���IJ�LM�FJ�@�L�G�
�O�O�G�$�� � ��'��<�A��L�L���!:�;�<�!O��
��<�A��L�L���!:�;�<�
	<��	�B������R��$�A��a���
�!��
�
�	�
#�8�,�	C�I�A�v��q�k�G� �1�1�3�J����S��_�a�0�� � ��'���&��#�6�A��G�G�M�M�!�,�E�A�r��O�O�B�M�M�!�$4�5�6�$�C�A��G�G�M�M�!�,�E�A�r��O�O�B�K�K��$7�8��O�O�B�M�M�&�3�,�$?�%B�$&�s�6�{�Q��$7�$?�$?�$A�C�C�	C�
�
�s�K
�
K	N)
rqrrrsr�r�rr�r�r�r�r�r�rrtrjrHr�r��sD���X�_�_�W�_�_�&E�F��G��((�TB�
� &�P.Crjr�c�Z�tjdi|��tjd��zS)Nrlr�rt)r�r�)r6s rHr�r��s&�����#��#�x�'9�'9�!�'D�D�Drj)r�rl)�M�<)�Hi)�Dr�)r�r��W0rw�)�days�hoursc��tjj|jd|ddd��}d}|j	|�}||k7�r=|dk(�r7	|j
rt
j|�}nt
j|�}|d}|d	}|d
}	tjj|dz|zdz|	zz
}
||
z}td|�d
|j
�d�tj��td|ztj��td|ztj��td|	ztj��td|
ztj��td|ztj��|j||�|j�y#t$r(}td|ztj��Yd}~�Od}~wwxYw)NrFrlrT)rHr�r�r�r�gr�r�rwr
rzt: z (�)r�zcurrentHour: %szcurrentMinute: %szcurrentSecond: %szr: %sz
result: %sz exception in diagnostic code: %s)rr@rnr5r�r�ryr��	localtime�	_MIDNIGHTr�rPr�r�rZrK)
rDr��expr�r�rer��currentHour�
currentMinute�
currentSecondr�r�r(s
             rH�test_compute_rolloverr�s���
�
�
�
6�
6��G�G�g�D�1�!�QU�7�W�����#�#�K�0���&�=��z�!�S��v�v� �K�K��4�� �N�N�;�7��"#�A�$�K�$%�a�D�M�$%�a�D�M��(�(�2�2�{�R�7G�7D�8E�HJ�7K�)�7*�+�A�)�1�_�F��!�R�V�V�4�3�:�:�F��+�k�9��
�
�K��-�
�=�C�J�J�O��-�
�=�C�J�J�O��'�A�+�C�J�J�7��,��/�c�j�j�A�	
����f�%�
���
��!�S��<�q�@�s�z�z�R�R��S�s�D6F)�)	G�2G�Gztest_compute_rollover_%sz>win32evtlog/win32evtlogutil/pywintypes required for this test.c��eZdZd�Zy)�NTEventLogHandlerTestc���d}tjd|�}tj|�}	tjjd�}tjddi�}|j|�|j�|j|tj|��tjtj z}d}d}	tj"|||	�}
|
D]1}|j$dk7r�t'j(||�}|d	k7r�/d
}nd|	z}|j+||��y#tj$r*}|jdk(rtjd���d}~wwxYw)
N�Application�test_loggingr
z#Insufficient privileges to run testrzTest Log MessageFrzTest Log Message
Tz3Record not found in event log, went back %d recordsr�)�win32evtlog�OpenEventLog�GetNumberOfEventLogRecordsrr@�NTEventLogHandler�
pywintypesr��winerrorr��SkipTestr�rVrK�
assertLess�EVENTLOG_BACKWARDS_READ�EVENTLOG_SEQUENTIAL_READ�ReadEventLog�
SourceName�win32evtlogutil�SafeFormatMessagerC)rD�logtype�elh�num_recsrRr(r��flagsr�r��eventsrs            rHr]z NTEventLogHandlerTest.test_basic�sY�����&�&�t�W�5���9�9�#�>��	�� � �2�2�>�B�A�
�!�!�5�*<�"=�>��	�����	���	�����+�"H�"H��"M�N��3�3��4�4�5�������)�)�#�u�g�>���	�A��|�|�~�-��!�3�3�A�w�?�C��,�,���E��	�D�g�M������3��'��1���	��z�z�Q���'�'�(M�N�N���	�s�D6�6E3�	%E.�.E3N)rqrrrsr]rtrjrHrr�s��(rjrc��eZdZd�Zy)�MiscTestCasec�D�hd�}tj|t|��y)N>r�r�Filtererr��
RootLoggerr��PlaceHolderr��currentframer��StrFormatStyler�r�r)�not_exported)r�check__all__r)rDr6s  rH�test__all__zMiscTestCase.test__all__�s��,��
	���T�7��FrjN)rqrrrsr8rtrjrHr/r/�s��Grjr/c�V�tjtjdd��y)N�LC_ALLr)r��enterModuleContextr�run_with_localertrjrH�setUpModuler=s������ 7� 7��"� E�Frj�__main__r�)F)�r�logging.handlers�logging.configr�r�r#r�rjr-r4r�r�rkr1r�r|rUr�r�r+rPr/�test.support.script_helperrrr�r�test.supportrrrr	r
rr�test.support.logging_helperr
r�r�r�ryr�r�r|�http.serverrr�urllib.parserr�socketserverrrrrrr'rr�r�r��HAVE_ASAN_FORK_BUGr��TestCaserrvr��SILENTr��TERSE�EFFUSIVEr�r�	TALKATIVEr��
CHATTERBOX�BORINGrxr�r�r�r�r�r�r6r8rr�r9r�r�r�r�r�rrr+r9rDrGrLr�r�rNrbr;r�r�r�rrTr@rFrQrUrc�IPV6_ENABLEDrfrlr�r�r�r�r�r�r�r@rDr�r�r�r�r�r�r�r
rr$r&r3r��
unittest.mockrUrWr�rx�tzinforvr�r�r�r�r�r�r�r�r�r�r�r�r(rxr�rr9rr�r�r�r�r�rrr�rr/r=rq�mainrtrjrH�<module>rSs ��"����
�����
�	��	��	��
�	�
�
�
�
��N��&�"�&�)�(�!��3��������:�+�D�D�6�3�3�	��$�H�O�O����E�G��
j'�x� � �j'�ZUI��UI�n<%�h�<%�L�������������	��	��
����F�F�Q�J�'���(��*�	�'��*��*��)�
�+�
�+��,�
�(���+�g�n�n�+�:����:�C'��C'�L�T2�(�T2�n1��1�#��-�-�#�
��
�'@��'@�XG;�U�%�%�G;�T0�6�0�d'�\�:�'�R1�L�"4�1�>-�L�"4�-�^�6�9��(�}�(�(��(�
!�� � �"�,��,�,�.��h��/�#��@C5��C5�L-��*�*�-�
�a�X�a�H!�� � �"�,��,�,�.�W+��W+�/�#�W+�t����W�V�Y�/�1H�I�&�-�&�J�&�!�� � �"�,��,�,�.�>:�(�>:�/�#�>:�@����W�V�Y�/�1H�I�(�1�(�J�(�!�� � �"�,��,�,�.�IB��IB�/�#�IB�V����W�V�Y�/�1H�I�&�-�&�J�&�����]�/�/�;�=�
6�-�
6�=�
6�!�� � �"�,��,�,�.�K �h�K �/�#�K �Z1��1�h-L�8�-L�`%K�8�%K�P.�
�
�#�	�G�)�)�	�	�W�%�%�3�3�	�	�%�+�+�	���s*�X�s*�j/9�(�9�.&�h�&�>	�w�(�(�	� �8� �F-��,�,�.�iP�x�iP�/�iP�V�7���_�-��#�0��0�0�2�]&�H�]&�3�]&�@�x���!����(�/�/��
�e��.�.�Y)�H�%�%�'9�Y)�x&�W�7�7�&�G�X�.�.�G�&A�H�A�,$;�X�$;�N	�	�$�w�*�*�$�T/�8�T/�nx/�(�x/�vJ0�H�J0�ZY#�h�'�'�Y#�x
i9��)�)�i9�X`>��-�`>�FH�8�H�25�l�5�,j�l�j�XeC�<�eC�PE��� �%�,���1�B�/�0�
�)d�I�D�#�*.�3� �B�(�*D�t�*K�Mb�c�S)d�X����[�"b�c� (�H� (�d� (�FG�8�$�$�G�G��z���H�M�M�O���E~�6�15�5�K�5�/�J�6��
�	��	�s$�["�[4�"[1�0[1�4[=�<[=