File: //lib/python3/dist-packages/twisted/test/__pycache__/test_logfile.cpython-310.pyc
o
�b�E � @ s� d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z d dl
mZ G dd� de�ZG dd� dej
�ZG d d
� d
e�ZdS )� N)�skipIf)�logfile�runtime)�TestCasec @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zeej�� d�dd � �Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)S )*�LogFileTestsz%
Test the rotating log file.
c C �4 | � � | _t�| j� d| _tj�| j| j�| _d S )Nztest.log��mktemp�dir�os�makedirs�name�path�join��self� r �;/usr/lib/python3/dist-packages/twisted/test/test_logfile.py�setUp �
zLogFileTests.setUpc C s2 t �| jd� t j�| j�rt �| jd� dS dS )z�
Restore back write rights on created paths: if tests modified the
rights, that will allow the paths to be removed easily afterwards.
� N)r �chmodr
r �existsr r r r �tearDown s �zLogFileTests.tearDownc C s. t �| j| j�}| �|j� | �t|j� dS )zf
L{BaseLogFile.shouldRotate} is abstract and must be implemented by
subclass.
N) r �BaseLogFiler
r
�
addCleanup�close�assertRaises�NotImplementedError�shouldRotate�r �logr r r �test_abstractShouldRotate$ s z&LogFileTests.test_abstractShouldRotatec C s� t �t�| j| j���}|�d� |�d� |�� |�d� W d � n1 s)w Y t| j ��}| �
|�� d� W d � dS 1 sGw Y dS )zn
Log files can be written to, flushed and closed. Closing a log file
also flushes it.
�123�456�7890N�
1234567890)�
contextlib�closingr �LogFiler
r
�write�flush�openr �assertEqual�read�r r! �fr r r �test_writing- s
�"�zLogFileTests.test_writingc C s\ t �tj| j| jdd����}|�d� |�d� |�d� | �tj �
| j � d��� | �tj �
| j � d��� |�d� | �tj �
| j � d��� | �tj �
| j � d��� | �tj �
| j � d ��� |�d
� | �tj �
| j � d ��� |�� | �tj �
| j � d ��� | �tj �
| j � d��� W d � n1 s�w Y | �
|�� g d
�� dS )zq
Rotating log files autorotate after a period of time, and can also be
manually rotated.
�
)�rotateLengthr# �4567890�11111111111�.1�.2� �.3�3�.4N)� � � )r'