§
    Ètºf€G  ã                  óÀ   — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
mZ d dlmZ  G d„ de¦  «        Z G d„ d	e
j        ¦  «        Z G d
„ de¦  «        ZdS )é    )ÚannotationsN)ÚskipIf)ÚlogfileÚruntime)ÚTestCasec                  óü   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z eej                             ¦   «         d¦  «        dd„¦   «         Zdd„Zdd„Zdd„Zdd„ZdS )ÚLogFileTestsz%
    Test the rotating log file.
    ÚreturnÚNonec                óÖ   — |                       ¦   «         | _        t          j        | j        ¦  «         d| _        t          j                             | j        | j        ¦  «        | _        d S )Nztest.log©ÚmktempÚdirÚosÚmakedirsÚnameÚpathÚjoin©Úselfs    úX/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/test/test_logfile.pyÚsetUpzLogFileTests.setUp   sI   € Ø—;’;‘=”=ˆŒÝ
Œ�D”HÑÔÐØˆŒ	Ý”G—L’L ¤¨4¬9Ñ5Ô5ˆŒ	ˆ	ˆ	ó    c                óº   — t          j        | j        d¦  «         t           j                             | j        ¦  «        rt          j        | j        d¦  «         dS dS )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   s    r   ÚtearDownzLogFileTests.tearDown   sT   € õ
 	Œ�”˜5Ñ!Ô!Ð!ÝŒ7�>Š>˜$œ)Ñ$Ô$ð 	'ÝŒH�T”Y Ñ&Ô&Ð&Ð&Ð&ð	'ð 	'r   c                ó¸   — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         |                      t          |j        ¦  «         dS )zf
        L{BaseLogFile.shouldRotate} is abstract and must be implemented by
        subclass.
        N)	r   ÚBaseLogFiler   r   Ú
addCleanupÚcloseÚassertRaisesÚNotImplementedErrorÚshouldRotate©r   Úlogs     r   Útest_abstractShouldRotatez&LogFileTests.test_abstractShouldRotate$   sN   € õ
 Ô! $¤)¨T¬XÑ6Ô6ˆØ�Š˜œ	Ñ"Ô"Ð"Ø×ÒÕ-¨sÔ/?Ñ@Ô@Ð@Ð@Ð@r   c                óè  — t          j        t          j        | j        | j        ¦  «        ¦  «        5 }|                     d¦  «         |                     d¦  «         |                     ¦   «          |                     d¦  «         ddd¦  «         n# 1 swxY w Y   t          | j	        ¦  «        5 }|  
                    |                     ¦   «         d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )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'   Úfs      r   Útest_writingzLogFileTests.test_writing-   sI  € õ
 Ô¥¤°´	¸4¼8Ñ DÔ DÑEÔEð 	ÈØ�IŠI�eÑÔÐØ�IŠI�eÑÔÐØ�IŠI‰KŒKˆKØ�IŠI�fÑÔÐð		ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ �$”)‰_Œ_ð 	5 Ø×Ò˜QŸVšV™XœX |Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5ð 	5ð 	5s$   ²ABÂBÂBÂ1)C'Ã'C+Ã.C+c                óŠ  — t          j        t          j        | j        | j        d¬¦  «        ¦  «        5 }|                     d¦  «         |                     d¦  «         |                     d¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         |                     d¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         |                      t          j	         
                    | j	        › d	�¦  «        ¦  «         |                     d
¦  «         |                      t          j	         
                    | j	        › d	�¦  «        ¦  «         |                     ¦   «          |                      t          j	         
                    | j	        › d	�¦  «        ¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         ddd¦  «         n# 1 swxY w Y   |                      |                     ¦   «         g d¢¦  «         dS )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.   r/   r   r0   r   r   r1   Ú
assertTruer   r   r   ÚassertFalseÚrotater4   ÚlistLogsr&   s     r   Útest_rotationzLogFileTests.test_rotation;   so  € õ ÔÝŒO˜DœI t¤x¸bÐAÑAÔAñ
ô 
ð 	?àà�IŠI�eÑÔÐØ�IŠI�iÑ Ô Ð Ø�IŠI�hÑÔÐØ�OŠO�BœGŸNšN¨d¬iÐ+;Ð+;Ð+;Ñ<Ô<Ñ=Ô=Ð=Ø×Ò�RœWŸ^š^¨t¬yÐ,<Ð,<Ð,<Ñ=Ô=Ñ>Ô>Ð>Ø�IŠI�b‰MŒMˆMØ�OŠO�BœGŸNšN¨d¬iÐ+;Ð+;Ð+;Ñ<Ô<Ñ=Ô=Ð=Ø�OŠO�BœGŸNšN¨d¬iÐ+;Ð+;Ð+;Ñ<Ô<Ñ=Ô=Ð=Ø×Ò�RœWŸ^š^¨t¬yÐ,<Ð,<Ð,<Ñ=Ô=Ñ>Ô>Ð>Ø�IŠI�c‰NŒNˆNØ×Ò�RœWŸ^š^¨t¬yÐ,<Ð,<Ð,<Ñ=Ô=Ñ>Ô>Ð>ð �JŠJ‰LŒLˆLØ�OŠO�BœGŸNšN¨d¬iÐ+;Ð+;Ð+;Ñ<Ô<Ñ=Ô=Ð=Ø×Ò�RœWŸ^š^¨t¬yÐ,<Ð,<Ð,<Ñ=Ô=Ñ>Ô>Ð>ð'	?ð 	?ð 	?ñ 	?ô 	?ð 	?ð 	?ð 	?ð 	?ð 	?ð 	?øøøð 	?ð 	?ð 	?ð 	?ð* 	×Ò˜Ÿš™œ¨¨¨Ñ3Ô3Ð3Ð3Ð3s   ´IJÊJÊJc                ód  — t          j        t          j        | j        | j        ¦  «        ¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t          j        | j        | j        ¦  «        }|                      |j        ¦  «         |  	                    |j
        d¦  «         |  	                    |j                             ¦   «         |j
        ¦  «         |                     d¦  «         |                     d¦  «         d}|  	                    |j
        t          |¦  «        ¦  «         |  	                    |j                             ¦   «         |j
        ¦  «         |j        }|                     dd¦  «         |  	                    |                     ¦   «         |¦  «         dS )a  
        Log files can be written to, closed. Their size is the number of
        bytes written to them. Everything that was written to them can
        be read, even if the writing happened on separate occasions,
        and even if the log file was closed in between.
        Ú
0123456789Nr:   Úabcs   defÿs   0123456789abcdefÿr   )r.   r/   r   r0   r   r   r1   r!   r"   r4   ÚsizeÚ_fileÚtellÚlenÚseekr5   )r   r'   ÚexpectResultr7   s       r   Útest_appendzLogFileTests.test_appendX   s™  € õ Ô¥¤°´	¸4¼8Ñ DÔ DÑEÔEð 	$ÈØ�IŠI�lÑ#Ô#Ð#ð	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$õ Œo˜dœi¨¬Ñ2Ô2ˆØ�Š˜œ	Ñ"Ô"Ð"Ø×Ò˜œ 2Ñ&Ô&Ð&Ø×Ò˜œŸšÑ)Ô)¨3¬8Ñ4Ô4Ð4Ø�	Š	�%ÑÔÐØ�	Š	�*ÑÔÐØ.ˆØ×Ò˜œ¥3 |Ñ#4Ô#4Ñ5Ô5Ð5Ø×Ò˜œŸšÑ)Ô)¨3¬8Ñ4Ô4Ð4ØŒIˆØ	�Šˆq�!‰ŒˆØ×Ò˜Ÿš™œ <Ñ0Ô0Ð0Ð0Ð0s   ²AÁAÁAc                ó„  — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         |                     d¦  «         |                     d¦  «         |                     ¦   «          |                     d¦  «         |                     ¦   «          |  	                    | 
                    ¦   «         dg¦  «         t          j        |                     ¦   «         ¦  «        5 }|j                             d¦  «         |  	                    |                     ¦   «         dg¦  «         |  	                    |                     ¦   «         g ¦  «         ddd¦  «         n# 1 swxY w Y   t          j        |                     d¦  «        ¦  «        5 }|  	                    |                     ¦   «         ddg¦  «         |  	                    |                     ¦   «         g ¦  «         ddd¦  «         n# 1 swxY w Y   |                      t&          |j        d¦  «         |                      t(          |j        d¦  «         |                     ¦   «          |  	                    | 
                    ¦   «         ddg¦  «         t          j        |                     d¦  «        ¦  «        5 }|j                             d¦  «         |  	                    |                     ¦   «         dg¦  «         |  	                    |                     ¦   «         g ¦  «         ddd¦  «         n# 1 swxY w Y   t          j        |                     d¦  «        ¦  «        5 }|  	                    |                     ¦   «         ddg¦  «         |  	                    |                     ¦   «         g ¦  «         ddd¦  «         dS # 1 swxY w Y   dS )	a[  
        Various tests for log readers.

        First of all, log readers can get logs by number and read what
        was written to those log files. Getting nonexistent log files
        raises C{ValueError}. Using anything other than an integer
        index raises C{TypeError}. As logs get older, their log
        numbers increase.
        zabc
zdef
zghi
rD   r   NrE   Ú1)r   r0   r   r   r!   r"   r1   rI   r2   r4   rJ   r.   r/   ÚgetCurrentLogrP   rS   Ú	readLinesÚgetLogr#   Ú
ValueErrorÚ	TypeError)r   r'   Úreaders      r   Útest_logReaderzLogFileTests.test_logReadero   s  € õ Œo˜dœi¨¬Ñ2Ô2ˆØ�Š˜œ	Ñ"Ô"Ð"Ø�	Š	�'ÑÔÐØ�	Š	�'ÑÔÐØ�
Š
‰ŒˆØ�	Š	�'ÑÔÐØ�	Š	‰Œˆð 	×Ò˜Ÿš™œ¨!¨Ñ-Ô-Ð-ÝÔ × 1Ò 1Ñ 3Ô 3Ñ4Ô4ð 	5¸ØŒL×Ò˜aÑ Ô Ð Ø×Ò˜V×-Ò-Ñ/Ô/°'°Ñ;Ô;Ð;Ø×Ò˜V×-Ò-Ñ/Ô/°Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5õ Ô §
¢
¨1¡¤Ñ.Ô.ð 	5°&Ø×Ò˜V×-Ò-Ñ/Ô/°'¸7Ð1CÑDÔDÐDØ×Ò˜V×-Ò-Ñ/Ô/°Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5ð
 	×Ò�* c¤j°!Ñ4Ô4Ð4Ø×Ò�) S¤Z°Ñ5Ô5Ð5ð 	�
Š
‰ŒˆØ×Ò˜Ÿš™œ¨!¨Q¨Ñ0Ô0Ð0ÝÔ §
¢
¨1¡¤Ñ.Ô.ð 	5°&ØŒL×Ò˜aÑ Ô Ð Ø×Ò˜V×-Ò-Ñ/Ô/°'°Ñ;Ô;Ð;Ø×Ò˜V×-Ò-Ñ/Ô/°Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5õ Ô §
¢
¨1¡¤Ñ.Ô.ð 	5°&Ø×Ò˜V×-Ò-Ñ/Ô/°'¸7Ð1CÑDÔDÐDØ×Ò˜V×-Ò-Ñ/Ô/°Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5ð 	5ð 	5sL   Ã0A,E(Å(E,Å/E,ÆAG9Ç9G=È G=Ê+A,L#Ì#L'Ì*L'ÍAN5Î5N9Î<N9c                ó  — t          | j        d¦  «        5  	 ddd¦  «         n# 1 swxY w Y   t          j        | j        ¦  «        }|                      |j        ¦  «         |                      g |                     d¦  «        ¦  «         dS )zB
        L{LogReader.readLines} supports reading no line.
        ÚwNr   )r3   r   r   Ú	LogReaderr!   r"   r4   rY   )r   r]   s     r   Útest_LogReaderReadsZeroLinez(LogFileTests.test_LogReaderReadsZeroLineš   sÀ   € õ
 �$”)˜SÑ!Ô!ð 	ð 	Øð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ Ô" 4¤9Ñ-Ô-ˆØ�Š˜œÑ%Ô%Ð%Ø×Ò˜˜V×-Ò-¨aÑ0Ô0Ñ1Ô1Ð1Ð1Ð1s   –$¤(«(c                ó  — t          | j        d¦  «                             ¦   «          t          j        | j        d¦  «         t          j        | j        ¦  «        t
          j                 }t          j        | j	        | j
        ¦  «        }|                      |j        ¦  «         |                     d¦  «         |                     ¦   «          |                      |t          j        | j        ¦  «        t
          j                 ¦  «         dS )zH
        Check rotated files have same permissions as original.
        r`   éÇ  rN   N)r3   r   r"   r   r   ÚstatÚST_MODEr   r0   r   r   r!   r1   rI   r4   )r   Úmoder'   s      r   Útest_modePreservationz"LogFileTests.test_modePreservation¦   sÅ   € õ 	ˆTŒY˜ÑÔ×"Ò"Ñ$Ô$Ð$Ý
Œ�”˜EÑ"Ô"Ð"ÝŒw�t”yÑ!Ô!¥$¤,Ô/ˆÝŒo˜dœi¨¬Ñ2Ô2ˆØ�Š˜œ	Ñ"Ô"Ð"Ø�	Š	�%ÑÔÐØ�
Š
‰ŒˆØ×Ò˜�rœw t¤yÑ1Ô1µ$´,Ô?Ñ@Ô@Ð@Ð@Ð@r   c                óÞ  — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         |                     d¦  «         t          j        | j        d¦  «         	 t          t          j
                             | j        d¦  «        d¦  «        }|                     ¦   «          dS # t          $ r Y nw xY w|                     ¦   «          |                     d¦  «         |                     ¦   «          |j        }|                      |                     ¦   «         d¦  «         |                     dd¦  «         |                      |                     ¦   «         d	¦  «         dS )
zH
        Check it keeps working when permission on dir changes.
        rN   ém  Úxxxr`   NÚdefé   r   s   abcdef)r   r0   r   r   r!   r"   r1   r   r   r3   r   r   ÚOSErrorrI   r2   rP   r4   rQ   rS   r5   r6   s      r   Útest_noPermissionzLogFileTests.test_noPermission³   s9  € õ Œo˜dœi¨¬Ñ2Ô2ˆØ�Š˜œ	Ñ"Ô"Ð"Ø�	Š	�%ÑÔÐõ 	Œ�”˜5Ñ!Ô!Ð!ð	Ý•R”W—\’\ $¤(¨EÑ2Ô2°CÑ8Ô8ˆAð �GŠG‰IŒIˆIØˆFøõ	 ð 	ð 	ð 	ØˆDð	øøøð 	�
Š
‰Œˆà�	Š	�%ÑÔÐØ�	Š	‰ŒˆàŒIˆØ×Ò˜Ÿš™œ 1Ñ%Ô%Ð%Ø	�Šˆq�!‰ŒˆØ×Ò˜Ÿš™œ 9Ñ-Ô-Ð-Ð-Ð-s   Á*3B3 Â3
C Â?C c                ó|  — t          j        | j        | j        dd¬¦  «        }|                      |j        ¦  «         |                     d¦  «         |                     d¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         |                     d¦  «         |                      t          j	         
                    | j	        › d�¦  «        ¦  «         |                     d	¦  «         |                      t          j	         
                    | j	        › d
�¦  «        ¦  «         t          | j	        › d
�¦  «        5 }|                      |                     ¦   «         d¦  «         ddd¦  «         n# 1 swxY w Y   |                     d¦  «         t          | j	        › d
�¦  «        5 }|                      |                     ¦   «         d¦  «         ddd¦  «         n# 1 swxY w Y   |                      t          j	         
                    | j	        › d�¦  «        ¦  «         dS )zl
        Test it respect the limit on the number of files when maxRotatedFiles
        is not None.
        r:   rF   )r;   ÚmaxRotatedFilesr=   Ú22222222222r>   Ú33333333333r?   Ú44444444444rA   NÚ55555555555rC   )r   r0   r   r   r!   r"   r1   rG   r   r   r   r3   r4   r5   rH   ©r   r'   Úfps      r   Útest_maxNumberOfLogz LogFileTests.test_maxNumberOfLogÒ   sW  € õ
 Œo˜dœi¨¬ÀÐTUÐVÑVÔVˆØ�Š˜œ	Ñ"Ô"Ð"Ø�	Š	�(ÑÔÐØ�	Š	�(ÑÔÐØ�Š�œŸš¨$¬)Ð'7Ð'7Ð'7Ñ8Ô8Ñ9Ô9Ð9à�	Š	�(ÑÔÐØ�Š�œŸš¨$¬)Ð'7Ð'7Ð'7Ñ8Ô8Ñ9Ô9Ð9à�	Š	�(ÑÔÐØ�Š�œŸš¨$¬)Ð'7Ð'7Ð'7Ñ8Ô8Ñ9Ô9Ð9Ý�T”YÐ"Ð"Ð"Ñ#Ô#ð 	2 rØ×Ò˜RŸWšW™YœY¨Ñ1Ô1Ð1ð	2ð 	2ð 	2ñ 	2ô 	2ð 	2ð 	2ð 	2ð 	2ð 	2ð 	2øøøð 	2ð 	2ð 	2ð 	2ð 	�	Š	�(ÑÔÐÝ�T”YÐ"Ð"Ð"Ñ#Ô#ð 	2 rØ×Ò˜RŸWšW™YœY¨Ñ1Ô1Ð1ð	2ð 	2ð 	2ñ 	2ô 	2ð 	2ð 	2ð 	2ð 	2ð 	2ð 	2øøøð 	2ð 	2ð 	2ð 	2à×Ò�œŸš¨4¬9Ð(8Ð(8Ð(8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:s$   Å)FÆFÆFÇ)G7Ç7G;Ç>G;c                ó:  — t          j        | j        | j        dd¬¦  «        }|                      |j        ¦  «         t           j                             | j        dd¬¦  «        }|                      |j        ¦  «         |                      |j        |j        ¦  «         |                      t          j         
                    |j        ¦  «        |j        ¦  «         |                      |j        |j        ¦  «         |                      |j        |j        ¦  «         dS )z/
        Test the fromFullPath method.
        r:   r   ©ÚdefaultModeN)r   r0   r   r   r!   r"   ÚfromFullPathr   r4   r   Úabspathr;   r{   )r   Úlog1Úlog2s      r   Útest_fromFullPathzLogFileTests.test_fromFullPathê   sæ   € õ Œ˜tœy¨$¬(°BÀEÐJÑJÔJˆØ�Š˜œ
Ñ#Ô#Ð#ÝŒ×+Ò+¨D¬I°rÀuÐ+ÑMÔMˆØ�Š˜œ
Ñ#Ô#Ð#Ø×Ò˜œ D¤IÑ.Ô.Ð.Ø×Ò�œŸš¨¬Ñ3Ô3°T´YÑ?Ô?Ð?Ø×Ò˜Ô*¨DÔ,=Ñ>Ô>Ð>Ø×Ò˜Ô)¨4Ô+;Ñ<Ô<Ð<Ð<Ð<r   c                ó  — t          | j        d¦  «        5  t          j        | j        d¦  «         t	          j        t          j        | j        ¦  «        t          j                 ¦  «        }ddd¦  «         n# 1 swxY w Y   t          j        | j	        | j
        ¦  «        }|                      t	          j        t          j        | j        ¦  «        t          j                 ¦  «        |¦  «         |                      |j        ¦  «         dS )zx
        Test the default permission of the log file: if the file exist, it
        should keep the permission.
        Úwbrd   N)r3   r   r   r   re   ÚS_IMODErf   r   r0   r   r   r4   r!   r"   )r   ÚcurrentModer~   s      r   Útest_defaultPermissionsz$LogFileTests.test_defaultPermissions÷   s  € õ
 �$”)˜TÑ"Ô"ð 	Ið 	IÝŒH�T”Y Ñ&Ô&Ð&Ýœ,¥r¤w¨t¬yÑ'9Ô'9½$¼,Ô'GÑHÔHˆKð	Ið 	Ið 	Iñ 	Iô 	Ið 	Ið 	Ið 	Ið 	Ið 	Ið 	Iøøøð 	Ið 	Ið 	Ið 	Iõ Œ˜tœy¨$¬(Ñ3Ô3ˆØ×Ò�œ¥b¤g¨d¬iÑ&8Ô&8½¼Ô&FÑGÔGÈÑUÔUÐUØ�Š˜œ
Ñ#Ô#Ð#Ð#Ð#s   –AA8Á8A<Á?A<c                óŠ  — t          j        | j        | j        d¬¦  «        }|                      |j        ¦  «         t          j        t          j        | j	        ¦  «        t          j
                 ¦  «        }t          j                             ¦   «         r|                      |d¦  «         dS |                      |d¦  «         dS )zG
        Test specifying the permissions used on the log file.
        é6   rz   é$  N)r   r0   r   r   r!   r"   re   rƒ   r   r   rf   r   ÚplatformÚ	isWindowsr4   )r   r~   rg   s      r   Útest_specifiedPermissionsz&LogFileTests.test_specifiedPermissions  s£   € õ Œ˜tœy¨$¬(ÀÐFÑFÔFˆØ�Š˜œ
Ñ#Ô#Ð#ÝŒ|�BœG D¤IÑ.Ô.­t¬|Ô<Ñ=Ô=ˆÝÔ×%Ò%Ñ'Ô'ð 	*à×Ò˜T 5Ñ)Ô)Ð)Ð)Ð)à×Ò˜T 5Ñ)Ô)Ð)Ð)Ð)r   zCan't test reopen on Windowsc                óÚ  — t          j        t          j        | j        | j        ¦  «        ¦  «        5 }|                     d¦  «         t          j         	                    | j        d¦  «        }t          j
        | j        |¦  «         |                     ¦   «          |                     d¦  «         ddd¦  «         n# 1 swxY w Y   t          | j        ¦  «        5 }|                      |                     ¦   «         d¦  «         ddd¦  «         n# 1 swxY w Y   t          |¦  «        5 }|                      |                     ¦   «         d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z‹
        L{logfile.LogFile.reopen} allows to rename the currently used file and
        make L{logfile.LogFile} create a new file.
        Úhello1zsave.logÚhello2N)r.   r/   r   r0   r   r   r1   r   r   r   ÚrenameÚreopenr3   r4   r5   )r   r~   ÚsavePathr7   s       r   Útest_reopenzLogFileTests.test_reopen  sÞ  € õ Ô¥¤°´	¸4¼8Ñ DÔ DÑEÔEð 	!ÈØ�JŠJ�xÑ Ô Ð Ý”w—|’| D¤H¨jÑ9Ô9ˆHÝŒI�d”i Ñ*Ô*Ð*Ø�KŠK‰MŒMˆMØ�JŠJ�xÑ Ô Ð ð	!ð 	!ð 	!ñ 	!ô 	!ð 	!ð 	!ð 	!ð 	!ð 	!ð 	!øøøð 	!ð 	!ð 	!ð 	!õ �$”)‰_Œ_ð 	1 Ø×Ò˜QŸVšV™XœX xÑ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1å�(‰^Œ^ð 	1˜qØ×Ò˜QŸVšV™XœX xÑ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1ð 	1ð 	1s6   ²A>B<Â<C ÃC Ã)DÄDÄDÄ*)E Å E$Å'E$c                ó¨   — |                       t          t          j        | j        d¦  «        }|                      |j        t          j        ¦  «         dS )zR
        Specifying an invalid directory to L{LogFile} raises C{IOError}.
        Úthis_dir_does_not_existN)r#   ÚIOErrorr   r0   r   r4   ÚerrnoÚENOENT)r   Úes     r   Útest_nonExistentDirz LogFileTests.test_nonExistentDir"  sI   € ð ×ÒÝ•W”_ d¤iÐ1Jñ
ô 
ˆð 	×Ò˜œ¥%¤,Ñ/Ô/Ð/Ð/Ð/r   c                ó.  — t           j                             ¦   «         rd\  }}d}nd\  }}d}t          j        ||d¬¦  «        }|                      |j        ¦  «         |                      |j        |¦  «         |                      |j	        d¦  «         dS )z„
        Opening a L{LogFile} which can be read and write but whose mode can't
        be changed doesn't trigger an error.
        )ÚNULr@   r›   )Únullz/devz	/dev/nullrj   rz   N)
r   r‰   rŠ   r   r0   r!   r"   r4   r   r{   )r   r   Ú	directoryÚexpectedPathr'   s        r   Útest_cantChangeFileModez$LogFileTests.test_cantChangeFileMode+  s™   € õ
 Ô×%Ò%Ñ'Ô'ð 	'Ø'‰OˆD�)Ø ˆLˆLà,‰OˆD�)Ø&ˆLåŒo˜d I¸5ÐAÑAÔAˆØ�Š˜œ	Ñ"Ô"Ð"à×Ò˜œ <Ñ0Ô0Ð0Ø×Ò˜œ¨%Ñ0Ô0Ð0Ð0Ð0r   c                óÞ  — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         t          |j        › d�d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t          |j        › d�d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   |  	                    dg| 
                    ¦   «         ¦  «         dS )zl
        L{LogFile.listLogs} doesn't choke if it encounters a file with an
        unexpected name.
        r>   r`   r*   Nz	.bad-filerD   )r   r0   r   r   r!   r"   r3   r   r1   r4   rJ   rv   s      r   Ú test_listLogsWithBadlyNamedFilesz-LogFileTests.test_listLogsWithBadlyNamedFiles=  sJ  € õ
 Œo˜dœi¨¬Ñ2Ô2ˆØ�Š˜œ	Ñ"Ô"Ð"å�S”X�/�/�/ 3Ñ'Ô'ð 	¨2Ø�HŠH�U‰OŒOˆOð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	å�S”XÐ(Ð(Ð(¨#Ñ.Ô.ð 	°"Ø�HŠH�U‰OŒOˆOð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	×Ò˜!˜˜cŸlšl™nœnÑ-Ô-Ð-Ð-Ð-s$   ÁA4Á4A8Á;A8ÂB9Â9B=Ã B=c                ó€  — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         t          dd¦  «        D ]I}t          |j        › d|› �d¦  «        5 }| 	                    d¦  «         ddd¦  «         n# 1 swxY w Y   ŒJ|  
                    ddg|                     ¦   «         ¦  «         dS )	zR
        L{LogFile.listLogs} ignores log files which rotated suffix is 0.
        r   rF   ú.r`   r*   NrD   rE   )r   r0   r   r   r!   r"   Úranger3   r   r1   r4   rJ   )r   r'   Úirw   s       r   Ú%test_listLogsIgnoresZeroSuffixedFilesz2LogFileTests.test_listLogsIgnoresZeroSuffixedFilesL  sð   € õ Œo˜dœi¨¬Ñ2Ô2ˆØ�Š˜œ	Ñ"Ô"Ð"å�q˜!‘”ð 	 ð 	 ˆAÝ˜œÐ'Ð' AÐ'Ð'¨Ñ-Ô-ð  °Ø—’˜‘”�ð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  øð 	×Ò˜!˜Q˜ §¢¡¤Ñ0Ô0Ð0Ð0Ð0s   Á&BÂB	ÂB	N©r
   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r(   r8   rK   rU   r^   rb   rh   ro   rx   r€   r…   r‹   r   r   r‰   rŠ   r’   r™   rŸ   r¡   r¦   © r   r   r	   r	      sÍ  € € € € € ðð ð6ð 6ð 6ð 6ð'ð 'ð 'ð 'ðAð Að Að Að5ð 5ð 5ð 5ð4ð 4ð 4ð 4ð:1ð 1ð 1ð 1ð.)5ð )5ð )5ð )5ðV
2ð 
2ð 
2ð 
2ðAð Að Að Að.ð .ð .ð .ð>;ð ;ð ;ð ;ð0=ð =ð =ð =ð
$ð 
$ð 
$ð 
$ð*ð *ð *ð *ð €VˆGÔ×&Ò&Ñ(Ô(Ð*HÑIÔIð1ð 1ð 1ñ JÔIð1ð"0ð 0ð 0ð 0ð1ð 1ð 1ð 1ð$.ð .ð .ð .ð1ð 1ð 1ð 1ð 1ð 1r   r	   c                  ó"   — e Zd ZdZd
d„Zdd„Zd	S )ÚRiggedDailyLogFileç        r
   r   c                óv   — t           j                             | ¦  «         |                      ¦   «         | _        d S )N)r   ÚDailyLogFileÚ	_openFileÚtoDateÚlastDater   s    r   r²   zRiggedDailyLogFile._openFile]  s,   € ÝÔ×&Ò& tÑ,Ô,Ð,àŸš™œˆŒˆˆr   ÚargsÚfloatútuple[int, int, int]c                ót   — |rt          j        |Ž d d…         S t          j        | j        ¦  «        d d…         S )NrF   )ÚtimeÚgmtimeÚ_clock)r   rµ   s     r   r³   zRiggedDailyLogFile.toDateb  s;   € Øð 	*Ý”; Ð% b q bÔ)Ð)ÝŒ{˜4œ;Ñ'Ô'¨¨¨Ô+Ð+r   Nr§   )rµ   r¶   r
   r·   )r¨   r©   rª   r»   r²   r³   r¬   r   r   r®   r®   Z  sA   € € € € € Ø€Fð&ð &ð &ð &ð
,ð ,ð ,ð ,ð ,ð ,r   r®   c                  ó´   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„Z e	e
j                             ¦   «         d	¦  «        dd
„¦   «         Zdd„Zdd„Zdd„Zdd„ZdS )ÚDailyLogFileTestsz!
    Test rotating log file.
    r
   r   c                óÖ   — |                       ¦   «         | _        t          j        | j        ¦  «         d| _        t          j                             | j        | j        ¦  «        | _        d S )Nztestdaily.logr   r   s    r   r   zDailyLogFileTests.setUpm  sI   € Ø—;’;‘=”=ˆŒÝ
Œ�D”HÑÔÐØ#ˆŒ	Ý”G—L’L ¤¨4¬9Ñ5Ô5ˆŒ	ˆ	ˆ	r   c                óÞ  — t          j        t          | j        | j        ¦  «        ¦  «        5 }|                     d¦  «         |                     d¦  «         |                     ¦   «          |                     d¦  «         ddd¦  «         n# 1 swxY w Y   t          | j        ¦  «        5 }|  	                    | 
                    ¦   «         d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zO
        A daily log file can be written to like an ordinary log file.
        r*   r+   r,   Nr-   )r.   r/   r®   r   r   r1   r2   r3   r   r4   r5   r6   s      r   r8   zDailyLogFileTests.test_writings  sH  € õ ÔÕ 2°4´9¸d¼hÑ GÔ GÑHÔHð 	ÈCØ�IŠI�eÑÔÐØ�IŠI�eÑÔÐØ�IŠI‰KŒKˆKØ�IŠI�fÑÔÐð		ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ �$”)‰_Œ_ð 	5 Ø×Ò˜QŸVšV™XœX |Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5ð 	5ð 	5s$   ­ABÂBÂBÂ,)C"Ã"C&Ã)C&c                ób  ‡ ‡— t          ‰ j        ‰ j        ¦  «        Š‰                      ‰j        ¦  «         ˆˆ fd„t          d¦  «        D ¦   «         }d‰_        ‰                     d¦  «         d‰_        ‰                     d¦  «         d‰_        ‰                     d¦  «         ‰                      t          j
                             |d	         ¦  «        ¦  «         ‰                      t          j
                             |d
         ¦  «        ¦  «         d‰_        ‰                     d¦  «         ‰                      t          j
                             |d	         ¦  «        ¦  «         ‰                      t          j
                             |d
         ¦  «        ¦  «         ‰                      t          j
                             |d         ¦  «        ¦  «         d‰_        ‰                     d¦  «         ‰                      t          j
                             |d         ¦  «        ¦  «         dS )z/
        Daily log files rotate daily.
        c                óV   •— g | ]%}‰j         d z   ‰                     |dz  ¦  «        z   ‘Œ&S )r£   é€Q )r   Úsuffix)Ú.0Údayr'   r   s     €€r   ú
<listcomp>z3DailyLogFileTests.test_rotation.<locals>.<listcomp>†  s4   ø€ ÐPÐPÐPÀ�”˜S‘ 3§:¢:¨c°E©kÑ#:Ô#:Ñ:ÐPÐPÐPr   rF   r¯   r*   iÀ¨  r<   rÂ   r=   r   rD   i £ r@   rE   iô rB   N)r®   r   r   r!   r"   r¤   r»   r1   rG   r   r   r   rH   )r   Údaysr'   s   ` @r   rK   zDailyLogFileTests.test_rotation€  s¬  øø€ õ ! ¤¨D¬HÑ5Ô5ˆØ�Š˜œ	Ñ"Ô"Ð"ØPÐPÐPÐPÐPÅuÈQÁxÄxÐPÑPÔPˆð ˆŒ
Ø�	Š	�%ÑÔÐØˆŒ
Ø�	Š	�)ÑÔÐØˆŒ
Ø�	Š	�(ÑÔÐØ�Š�œŸš t¨A¤wÑ/Ô/Ñ0Ô0Ð0Ø×Ò�œŸš¨¨Q¬Ñ0Ô0Ñ1Ô1Ð1ØˆŒ
Ø�	Š	�"‰ŒˆØ�Š�œŸš t¨A¤wÑ/Ô/Ñ0Ô0Ð0Ø�Š�œŸš t¨A¤wÑ/Ô/Ñ0Ô0Ð0Ø×Ò�œŸš¨¨Q¬Ñ0Ô0Ñ1Ô1Ð1ØˆŒ
Ø�	Š	�#‰ŒˆØ×Ò�œŸš¨¨Q¬Ñ0Ô0Ñ1Ô1Ð1Ð1Ð1r   c                óÎ  — g d¢}t          | j        | j        ¦  «        }|                      |j        ¦  «         |D ]}|                     |¦  «         Œ|                     ¦   «          |                     d¦  «        }|                      |j        ¦  «         |                      || 	                    ¦   «         ¦  «         |  
                    t          |j        d¦  «         d|_        |                     ¦   «          |                     ¦   «          |                     d¦  «        }|                      |j        ¦  «         |                      || 	                    ¦   «         ¦  «         dS )zH
        Test retrieving log files with L{DailyLogFile.getLog}.
        )z1
z2
z3
r¯   rÂ   i�Q r   N)r®   r   r   r!   r"   r1   r2   rZ   r4   rY   r#   r[   r»   rI   )r   Údatar'   ÚdÚrs        r   Útest_getLogzDailyLogFileTests.test_getLogš  s*  € ð %Ð$Ð$ˆÝ  ¤¨D¬HÑ5Ô5ˆØ�Š˜œ	Ñ"Ô"Ð"Øð 	ð 	ˆAØ�IŠI�a‰LŒLˆLˆLØ�	Š	‰Œˆð �JŠJ�s‰OŒOˆØ�Š˜œÑ Ô Ð à×Ò˜˜qŸ{š{™}œ}Ñ-Ô-Ð-ð 	×Ò�* c¤j°%Ñ8Ô8Ð8àˆŒ
Ø	�Š‰	Œ	ˆ	Ø�
Š
‰ŒˆØ�JŠJ�q‰MŒMˆØ�Š˜œÑ Ô Ð Ø×Ò˜˜qŸ{š{™}œ}Ñ-Ô-Ð-Ð-Ð-r   c                óœ  — t          | j        | j        ¦  «        }|                      |j        ¦  «         |j        › d|                     |j        ¦  «        › �}t          |d¦  «        5 }| 	                    d¦  «         ddd¦  «         n# 1 swxY w Y   |j
        }|                     ¦   «          |                      ||j
        ¦  «         dS )zu
        L{DailyLogFile.rotate} doesn't do anything if they new log file already
        exists on the disk.
        r£   r`   r*   N)r®   r   r   r!   r"   r   rÃ   r´   r3   r1   rP   rI   r4   )r   r'   ÚnewFilePathrw   ÚpreviousFiles        r   Útest_rotateAlreadyExistsz*DailyLogFileTests.test_rotateAlreadyExistsµ  só   € õ
 ! ¤¨D¬HÑ5Ô5ˆØ�Š˜œ	Ñ"Ô"Ð"ð œÐ>Ð> C§J¢J¨s¬|Ñ$<Ô$<Ð>Ð>ˆÝ�+˜sÑ#Ô#ð 	 rØ�HŠH�U‰OŒOˆOð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	à”yˆØ�
Š
‰ŒˆØ×Ò˜ s¤yÑ1Ô1Ð1Ð1Ð1s   Á)BÂBÂBzVMaking read-only directories on Windows is too complex for this test to reasonably do.c                ód  — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         t          j        |j        d¦  «         |                      t          j        |j        d¦  «         |j	        }| 
                    ¦   «          |                      ||j	        ¦  «         dS )zƒ
        L{DailyLogFile.rotate} doesn't do anything if the directory containing
        the log files can't be written to.
        rˆ   ií  N)r   r±   r   r   r!   r"   r   r   r�   rP   rI   r4   ©r   r'   rÏ   s      r   Ú#test_rotatePermissionDirectoryNotOkz5DailyLogFileTests.test_rotatePermissionDirectoryNotOkÆ  sŽ   € õ Ô" 4¤9¨d¬hÑ7Ô7ˆØ�Š˜œ	Ñ"Ô"Ð"å
Œ�” Ñ&Ô&Ð&à�Š�œ #¤-°Ñ7Ô7Ð7Ø”yˆØ�
Š
‰ŒˆØ×Ò˜ s¤yÑ1Ô1Ð1Ð1Ð1r   c                ó  — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         t          j        |j        d¦  «         |j	        }| 
                    ¦   «          |                      ||j	        ¦  «         dS )zi
        L{DailyLogFile.rotate} doesn't do anything if the log file can't be
        written to.
        rˆ   N)r   r±   r   r   r!   r"   r   r   r   rP   rI   r4   rÒ   s      r   Útest_rotatePermissionFileNotOkz0DailyLogFileTests.test_rotatePermissionFileNotOkÚ  st   € õ
 Ô" 4¤9¨d¬hÑ7Ô7ˆØ�Š˜œ	Ñ"Ô"Ð"å
Œ�”˜5Ñ!Ô!Ð!Ø”yˆØ�
Š
‰ŒˆØ×Ò˜ s¤yÑ1Ô1Ð1Ð1Ð1r   c                óò   — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         t          j        d¦  «        }|                      d| 	                    |¦  «        ¦  «         dS )z~
        Test that L{DailyLogFile.toDate} converts its timestamp argument to a
        time tuple (year, month, day).
        )	éÐ  rD   rD   r   r   r   r   r   r   )r×   rD   rD   N)
r   r±   r   r   r!   r"   r¹   Úmktimer4   r³   )r   r'   Ú	timestamps      r   Útest_toDatezDailyLogFileTests.test_toDateç  sf   € õ
 Ô" 4¤9¨d¬hÑ7Ô7ˆØ�Š˜œ	Ñ"Ô"Ð"å”KÐ >Ñ?Ô?ˆ	Ø×Ò˜ s§z¢z°)Ñ'<Ô'<Ñ=Ô=Ð=Ð=Ð=r   c                ó  ‡ — d	ˆ fd„}t          j        ‰ j        ‰ j        ¦  «        }‰                      |j        ¦  «         ‰                      t          d|¦  «         |                     ¦   «         }‰  	                    g d¢|¦  «         dS )
aË  
        Test that L{DailyLogFile.toDate} returns today's date by default.

        By mocking L{time.localtime}, we ensure that L{DailyLogFile.toDate}
        returns the first 3 values of L{time.localtime} which is the current
        date.

        Note that we don't compare the *real* result of L{DailyLogFile.toDate}
        to the *real* current date, as there's a slight possibility that the
        date changes between the 2 function calls.
        rµ   Úobjectr
   ú	list[int]c                 ój   •— ‰                      d| ¦  «         t          t          dd¦  «        ¦  «        S )Nr¬   r   é	   )r4   Úlistr¤   )rµ   r   s    €r   Úmock_localtimezADailyLogFileTests.test_toDateDefaultToday.<locals>.mock_localtimeÿ  s/   ø€ Ø×Ò˜R Ñ&Ô&Ð&Ý�˜a ™œÑ$Ô$Ð$r   Ú	localtime)r   rD   rE   N)rµ   rÜ   r
   rÝ   )
r   r±   r   r   r!   r"   Úpatchr¹   r³   r4   )r   rá   r'   ÚlogDates   `   r   Útest_toDateDefaultTodayz)DailyLogFileTests.test_toDateDefaultTodayò  s�   ø€ ð	%ð 	%ð 	%ð 	%ð 	%ð 	%õ Ô" 4¤9¨d¬hÑ7Ô7ˆØ�Š˜œ	Ñ"Ô"Ð"à�
Š
•4˜ nÑ5Ô5Ð5Ø—*’*‘,”,ˆØ×Ò˜˜˜ GÑ,Ô,Ð,Ð,Ð,r   c                ó   — t          j        | j        | j        ¦  «        }|                      |j        ¦  «         d}t          j        |dz   ¦  «        }|                     |¦  «        }|  	                    ||¦  «         dS )zc
        Test that L{DailyLogFile.toDate} uses its arguments to create a new
        date.
        )iÞ  r:   é   )r   r   r   r   r   r   N)
r   r±   r   r   r!   r"   r¹   rØ   r³   r4   )r   r'   ÚdateÚsecondsrä   s        r   Ú#test_toDateUsesArgumentsToMakeADatez5DailyLogFileTests.test_toDateUsesArgumentsToMakeADate
  ss   € õ
 Ô" 4¤9¨d¬hÑ7Ô7ˆØ�Š˜œ	Ñ"Ô"Ð"àˆÝ”+˜d X™oÑ.Ô.ˆà—*’*˜WÑ%Ô%ˆØ×Ò˜˜wÑ'Ô'Ð'Ð'Ð'r   Nr§   )r¨   r©   rª   r«   r   r8   rK   rÌ   rÐ   r   r   r‰   rŠ   rÓ   rÕ   rÚ   rå   rê   r¬   r   r   r½   r½   h  s  € € € € € ðð ð6ð 6ð 6ð 6ð5ð 5ð 5ð 5ð2ð 2ð 2ð 2ð4.ð .ð .ð .ð62ð 2ð 2ð 2ð" €VØÔ×"Ò"Ñ$Ô$ð	!ñô ð
2ð 2ð 2ñô ð
2ð2ð 2ð 2ð 2ð	>ð 	>ð 	>ð 	>ð-ð -ð -ð -ð0(ð (ð (ð (ð (ð (r   r½   )Ú
__future__r   r.   r–   r   re   r¹   Úunittestr   Útwisted.pythonr   r   Útwisted.trial.unittestr   r	   r±   r®   r½   r¬   r   r   ú<module>rï      s#  ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø €€€Ø 	€	€	€	Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð à +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø +Ð +Ð +Ð +Ð +Ð +ðG1ð G1ð G1ð G1ð G1�8ñ G1ô G1ð G1ðT
,ð ,ð ,ð ,ð ,˜Ô-ñ ,ô ,ð ,ðn(ð n(ð n(ð n(ð n(˜ñ n(ô n(ð n(ð n(ð n(r   