HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/tornado/test/__pycache__/log_test.cpython-310.pyc
o

�h�"�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZddlmZddlmZejdd��ZGdd	�d	ej�ZGd
d�dej�ZGdd
�d
ej�ZdS)�N)�utf8)�LogFormatter�define_logging_options�enable_pretty_logging)�OptionParser)�basestring_typeccsD�t���tjdtd�dVWd�dS1swYdS)N�ignore)�category)�warnings�catch_warnings�simplefilter�BytesWarning�rr�H/usr/local/CyberCP/lib/python3.10/site-packages/tornado/test/log_test.py�ignore_bytes_warning s
�
"�rc@s^eZdZe�d�Zdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�LogFormatterTestsD(?s)\[E [0-9]{6} [0-9]{2}:[0-9]{2}:[0-9]{2} log_test:[0-9]+\] (.*)cCs�tdd�|_tjdi|j_d|j_t�d�|_d|j_t	�
�|_tj
�|jd�|_|�|j�|_|j�|j�|j�|j�dS)NF)�color��rzlog.out)r�	formatter�logging�ERROR�_colors�_normal�Logger�logger�	propagate�tempfile�mkdtemp�tempdir�os�path�join�filename�make_handler�handler�setFormatter�
addHandler��selfrrr�setUp.s
zLogFormatterTest.setUpcCs&|j��t�|j�t�|j�dS�N)r%�closer �unlinkr#�rmdirrr(rrr�tearDown?s
zLogFormatterTest.tearDowncCstj|dd�S)N�utf-8��encoding)r�FileHandler)r)r#rrrr$DszLogFormatterTest.make_handlercCsbt|jd��!}|����}tj�|�}|r!|�d�Wd�Std|��1s*wYdS)N�rb�zoutput didn't match regex: %r)	�openr#�read�stripr�LINE_RE�match�group�	Exception)r)�f�line�mrrr�
get_outputGs��zLogFormatterTest.get_outputcCs |j�d�|�|��d�dS)N�foosfoo)r�error�assertEqualr@r(rrr�test_basic_loggingPsz#LogFormatterTest.test_basic_loggingcCsPt��|j�d�|�|��ttd���Wd�dS1s!wYdS)N��)rrrBrCr@r�reprr(rrr�test_bytes_loggingTs"�z#LogFormatterTest.test_bytes_loggingcCszt��|j�d�d��Wd�n1swYttt�r-|�|��t	d��dS|�|��t	t
t	d����dS)N�ér)rrrB�encode�
issubclass�bytesrrCr@rrFr(rrr�test_utf8_loggingZs�
 z"LogFormatterTest.test_utf8_loggingcCsLztd��ty|j�d�Ynw|��}|�|d�|�d|�dS)NrEzcaught exceptionsException.*\\xe9s\n)r<r�	exceptionr@�assertRegex�assertNotIn)r)�outputrrr�test_bytes_exception_logginggs�z-LogFormatterTest.test_bytes_exception_loggingcCs$|j�d�|�|��td��dS)NrH)rrBrCr@rr(rrr�test_unicode_loggingssz%LogFormatterTest.test_unicode_loggingN)�__name__�
__module__�__qualname__�re�compiler9r*r/r$r@rDrGrLrQrRrrrrr's�	
rcs4eZdZ�fdd�Zdd�Zdd�Zdd�Z�ZS)	�EnablePrettyLoggingTestcs4t���t�|_t|j�t�d�|_d|j_dS)Nz-tornado.test.log_test.EnablePrettyLoggingTestF)	�superr*r�optionsrrrrrr(��	__class__rrr*ys


zEnablePrettyLoggingTest.setUpc
CsHt��}z{|d|j_t|j|jd�|�dt|jj��|j�	d�|jjd�
�t�|d�}|�dt|��t|ddd��}|�
|��d	�Wd�n1sUwYW|jjD]
}|�
�|��q_t�|d�D]}t�|�qqt�|�dS|jjD]
}|�
�|��q�t�|d�D]}t�|�q�t�|�w)
N�	/test_log�rZrr5�hellor�
/test_log*r0r1�^\[E [^]]*\] hello$)rrrZ�log_file_prefixrrrC�len�handlersrB�flush�globr6rNr7r,r r-r.�r)�tmpdir�	filenamesr=r%r#rrr�
test_log_file�s2��
�
z%EnablePrettyLoggingTest.test_log_filec
Cs<t��}zu|d|j_d|j_t|j|jd�|j�d�|jjd�	�t
�
|d�}|�dt|��t
|ddd	��}|�|��d
�Wd�n1sOwYW|jjD]
}|�	�|��qYt
�
|d�D]}t�|�qkt�|�dS|jjD]
}|�	�|��q~t
�
|d�D]}t�|�q�t�|�w)Nr]�timer^r_rr`r5r0r1ra)rrrZrb�log_rotate_moderrrBrdrerfrCrcr6rNr7r,r r-r.rgrrr�!test_log_file_with_timed_rotating�s2��
�
z9EnablePrettyLoggingTest.test_log_file_with_timed_rotatingc	Cslz%d|j_d|j_|jtt|j|jd�W|jjD]
}|��|�	�qdS|jjD]
}|��|�	�q*w)N�	some_path�
wrong_moder^)
rZrbrl�assertRaises�
ValueErrorrrrdrer,)r)r%rrr�test_wrong_rotate_mode_value�s �
�
�z4EnablePrettyLoggingTest.test_wrong_rotate_mode_value)rSrTrUr*rjrmrr�
__classcell__rrr[rrXxs
rXc@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�LoggingOptionTestz?Test the ability to enable and disable Tornado's logging hooks.Nc	Csdd}d}d�|||g�}tjtjd|g|pgtjtjd�}|��\}}|�|j	dd|�d|vS)	Nz7from tornado.options import options, parse_command_linez%import logging; logging.info("hello")�;z-c)�stdout�stderrrzprocess failed: %rshello)
r"�
subprocess�Popen�sys�
executable�PIPE�STDOUT�communicaterC�
returncode)	r)�	statement�args�IMPORT�LOG_INFO�program�procrvrwrrr�logs_present�s�zLoggingOptionTest.logs_presentcC�|�|�d��dS)N�pass��assertFalser�r(rrr�test_default��zLoggingOptionTest.test_defaultcCr�)N�parse_command_line()��
assertTruer�r(rrr�test_tornado_default�r�z&LoggingOptionTest.test_tornado_defaultcC�|�|�ddg��dS)Nr�z--logging=noner�r(rrr�test_disable_command_line��z+LoggingOptionTest.test_disable_command_linecCr�)Nr�z--logging=Noner�r(rrr�*test_disable_command_line_case_insensitive�r�z<LoggingOptionTest.test_disable_command_line_case_insensitivecCr�)Nz.options.logging = "none"; parse_command_line()r�r(rrr�test_disable_code_string���z*LoggingOptionTest.test_disable_code_stringcCr�)N�,options.logging = None; parse_command_line()r�r(rrr�test_disable_code_none�r�z(LoggingOptionTest.test_disable_code_nonecCr�)Nr�z--logging=infor�r(rrr�test_disable_override�s
��z'LoggingOptionTest.test_disable_overrider+)rSrTrU�__doc__r�r�r�r�r�r�r�r�rrrrrt�s
rt)�
contextlibrfrr rVrxrzr�unittestr
�tornado.escaper�tornado.logrrr�tornado.optionsr�tornado.utilr�contextmanagerr�TestCaserrXrtrrrr�<module>s&
Q@