+
    DfjG                        ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
Ht ^ RIHt  ! R R]4      t ! R R	]
P                  4      t ! R
 R]4      tR# )    )annotationsN)skipIf)logfileruntime)TestCasec                  F   ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R lt]! ]P*                  P-                  4       R4      R R  l4       tR! R" ltR# R$ ltR% R& ltR' R( ltR)tR*# )+LogFileTestsz
Test the rotating log file.
c                   V ^8  d   QhRR/#    returnNone )formats   ";/usr/lib/python3/dist-packages/twisted/test/test_logfile.py__annotate__LogFileTests.__annotate__        6 6t 6    c                	    V P                  4       V n        \        P                  ! V P                  4       R V n        \        P
                  P                  V P                  V P                  4      V n        R# )ztest.logNmktempdirosmakedirsnamepathjoinselfs   &r   setUpLogFileTests.setUp   sD    ;;=
DHH	GGLL4995	r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     ' '$ 'r   c                    \         P                  ! V P                  R4       \         P                  P	                  V P                  4      '       d$   \         P                  ! V P                  R4       R# R# )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   tearDownLogFileTests.tearDown   sD    
 	5!77>>$))$$HHTYY& %r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   $   s     A A4 Ar   c                    \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       V P                  \        VP                  4       R# )zN
L{BaseLogFile.shouldRotate} is abstract and must be implemented by
subclass.
N)	r   BaseLogFiler   r   
addCleanupcloseassertRaisesNotImplementedErrorshouldRotater    logs   & r   test_abstractShouldRotate&LogFileTests.test_abstractShouldRotate$   sE    
 !!$))TXX6		"-s/?/?@r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   -   s     5 5d 5r   c                   \         P                  ! \        P                  ! V P                  V P
                  4      4      ;_uu_ 4       pVP                  R4       VP                  R4       VP                  4        VP                  R4       RRR4       \        V P                  4      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       R#   + '       g   i     LX; i  + '       g   i     R# ; i)zV
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    r3   fs   &  r   test_writingLogFileTests.test_writing-   s    
 		488 DEEIIeIIeIIKIIf	 F $))__QVVX|4 _ FE __s   AC1!C/C,	/D 	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   ;   s     4 4t 4r   c                   \         P                  ! \        P                  ! V P                  V P
                  ^
R7      4      ;_uu_ 4       pVP                  R4       VP                  R4       VP                  R4       V P                  \        P                  P                  V P                   R24      4       V P                  \        P                  P                  V P                   R24      4       VP                  R4       V P                  \        P                  P                  V P                   R24      4       V P                  \        P                  P                  V P                   R24      4       V P                  \        P                  P                  V P                   R24      4       VP                  R4       V P                  \        P                  P                  V P                   R24      4       VP                  4        V P                  \        P                  P                  V P                   R24      4       V P                  \        P                  P                  V P                   R	24      4       R
R
R
4       V P                  XP                  4       . RO4       R
#   + '       g   i     L4; i)zY
Rotating log files autorotate after a period of time, and can also be
manually rotated.
)rotateLengthr8   4567890.1.2 .33.4N11111111111)   r      )r<   r=   r   r>   r   r   r?   
assertTruer   r   r'   assertFalserotaterB   listLogsr2   s   & r   test_rotationLogFileTests.test_rotation;   s    OODIItxxbA
 
IIeIIi IIhOOBGGNNdii[+;<=RWW^^tyyk,<=>IIbMOOBGGNNdii[+;<=OOBGGNNdii[+;<=RWW^^tyyk,<=>IIcNRWW^^tyyk,<=> JJLOOBGGNNdii[+;<=RWW^^tyyk,<=>'
* 	3+
 
s   
H>J44K	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   X   s     1 1T 1r   c                   \         P                  ! \        P                  ! V P                  V P
                  4      4      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! V P                  V P
                  4      pV P                  VP                  4       V P                  VP                  ^
4       V P                  VP                  P                  4       VP                  4       VP                  R4       VP                  R4       RpV P                  VP                  \        V4      4       V P                  VP                  P                  4       VP                  4       VP                  pVP                  ^ ^ 4       V P                  VP                  4       V4       R#   + '       g   i     ELd; i)z
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.

0123456789Nabcs   defs   0123456789abcdef)r<   r=   r   r>   r   r   r?   r-   r.   rB   size_filetelllenseekrC   )r    r3   expectResultrE   s   &   r   test_appendLogFileTests.test_appendX   s'    		488 DEEIIl# F oodii2		"2&)3884		%		*.3|#45)3884II	q!<0 FEEs   F55G	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   o   s     )5 )5 )5r   c                &   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       VP                  R4       VP                  R4       VP                  4        VP                  R4       VP                  4        V P                  VP                  4       ^.4       \        P                  ! VP                  4       4      ;_uu_ 4       pVP                  P                  ^ 4       V P                  VP!                  4       R.4       V P                  VP!                  4       . 4       RRR4       \        P                  ! VP#                  ^4      4      ;_uu_ 4       pV P                  VP!                  4       RR.4       V P                  VP!                  4       . 4       RRR4       V P%                  \&        VP"                  ^4       V P%                  \(        VP"                  R4       VP                  4        V P                  VP                  4       ^^.4       \        P                  ! VP#                  ^4      4      ;_uu_ 4       pVP                  P                  ^ 4       V P                  VP!                  4       R.4       V P                  VP!                  4       . 4       RRR4       \        P                  ! VP#                  ^4      4      ;_uu_ 4       pV P                  VP!                  4       RR.4       V P                  VP!                  4       . 4       RRR4       R#   + '       g   i     EL	; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)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
N1)r   r>   r   r   r-   r.   r?   rW   r@   rB   rX   r<   r=   getCurrentLogr`   rc   	readLinesgetLogr/   
ValueError	TypeError)r    r3   readers   &  r   test_logReaderLogFileTests.test_logReadero   s~    oodii2		"		'		'

		'		 	!- 1 1 344LLa V--/';V--/4 5 

1..&V--/'71CDV--/4 /
 	*cjj!4)SZZ5 	

!Q0

1..&LLa V--/';V--/4 / 

1..&V--/'71CDV--/4 /.' 544 /.. /. /..s4   'AM9AM%AM,7AM?M	M)	,M<	?N	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     
2 
2T 
2r   c                4   \        V P                  R4      ;_uu_ 4         RRR4       \        P                  ! V P                  4      pV P	                  VP
                  4       V P                  . VP                  ^ 4      4       R#   + '       g   i     Ln; i)z2
L{LogReader.readLines} supports reading no line.
wN)rA   r   r   	LogReaderr-   r.   rB   rk   )r    ro   s   & r   test_LogReaderReadsZeroLine(LogFileTests.test_LogReaderReadsZeroLine   sg    
 $))S!! " ""499-%V--a01 "!s   BB	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     A At Ar   c                R   \        V P                  R4      P                  4        \        P                  ! V P                  R4       \        P
                  ! V P                  4      \
        P                  ,          p\        P                  ! V P                  V P                  4      pV P                  VP                  4       VP                  R4       VP                  4        V P                  V\        P
                  ! V P                  4      \
        P                  ,          4       R# )z8
Check rotated files have same permissions as original.
rt     r^   N)rA   r   r.   r   r&   statST_MODEr   r>   r   r   r-   r?   rW   rB   )r    moder3   s   &  r   test_modePreservation"LogFileTests.test_modePreservation   s     	TYY""$
E"wwtyy!$,,/oodii2		"		%

rwwtyy1$,,?@r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     . .4 .r   c                   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       VP                  R4       \        P                  ! V P                  R4        \        \        P                  P                  V P                  R4      R4      pVP                  4        R#   \         d     Mi ; iTP                  4        TP                  R4       TP                  4        TP                  pT P!                  TP#                  4       ^4       TP%                  ^ ^ 4       T P!                  TP'                  4       R4       R# )z8
Check it keeps working when permission on dir changes.
r^   m  xxxrt   Ndefs   abcdef)r   r>   r   r   r-   r.   r?   r   r&   rA   r   r   OSErrorrW   r@   r`   rB   ra   rc   rC   rD   s   &  r   test_noPermissionLogFileTests.test_noPermission   s     oodii2		"		% 	5!	RWW\\$((E2C8A GGI	  		 	

		%		II1%	q!9-s   :4C   CCc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     ; ;T ;r   c                   \         P                  ! V P                  V P                  ^
^R7      pV P	                  VP
                  4       VP                  R4       VP                  R4       V P                  \        P                  P                  V P                   R24      4       VP                  R	4       V P                  \        P                  P                  V P                   R24      4       VP                  R
4       V P                  \        P                  P                  V P                   R24      4       \        V P                   R24      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       VP                  R4       \        V P                   R24      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       V P                  \        P                  P                  V P                   R24      4       R#   + '       g   i     L; i  + '       g   i     L`; i)zT
Test it respect the limit on the number of files when maxRotatedFiles
is not None.
)rJ   maxRotatedFilesrL   rM   rO   NrQ   rR   22222222222333333333334444444444455555555555)r   r>   r   r   r-   r.   r?   rU   r   r   r'   rA   rB   rC   rV   r    r3   fps   &  r   test_maxNumberOfLog LogFileTests.test_maxNumberOfLog   sy   
 oodiiTUV		"		(		($))B'789		($))B'789		($))B'789TYYKr"##rRWWY1 $ 			(TYYKr"##rRWWY1 $499+R(89: $# $#s   !H9!H2H/	2I	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     = =4 =r   c                   \         P                  ! V P                  V P                  ^
RR7      pV P	                  VP
                  4       \         P                  P                  V P                  ^
RR7      pV P	                  VP
                  4       V P                  VP                  VP                  4       V P                  \        P                  P                  VP                  4      VP                  4       V P                  VP                  VP                  4       V P                  VP                  VP                  4       R# )z
Test the fromFullPath method.
r%   defaultModeN)r   r>   r   r   r-   r.   fromFullPathr   rB   r   abspathrJ   r   )r    log1log2s   &  r   test_fromFullPathLogFileTests.test_fromFullPath   s     tyy$((BEJ

#++DIIru+M

#DII.3TYY?**D,=,=>))4+;+;<r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     
$ 
$ 
$r   c                   \        V P                  R4      ;_uu_ 4        \        P                  ! V P                  R4       \        P
                  ! \        P                  ! V P                  4      \        P                  ,          4      pRRR4       \        P                  ! V P                  V P                  4      pV P                  \        P
                  ! \        P                  ! V P                  4      \        P                  ,          4      X4       V P                  VP                  4       R#   + '       g   i     L; i)z`
Test the default permission of the log file: if the file exist, it
should keep the permission.
wbrz   N)rA   r   r   r&   r{   S_IMODEr|   r   r>   r   r   rB   r-   r.   )r    currentModer   s   &  r   test_defaultPermissions$LogFileTests.test_defaultPermissions   s    
 $))T""HHTYY&,,rwwtyy'9$,,'GHK # tyy$((3bggdii&8&FGU

# #"s   A+D33E	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     * *4 *r   c                   \         P                  ! V P                  V P                  ^6R7      pV P	                  VP
                  4       \        P                  ! \        P                  ! V P                  4      \        P                  ,          4      p\        P                  P                  4       '       d   V P                  VR4       R# V P                  V^64       R# )z7
Test specifying the permissions used on the log file.
r   $  N)r   r>   r   r   r-   r.   r{   r   r   r   r|   r   platform	isWindowsrB   )r    r   r}   s   &  r   test_specifiedPermissions&LogFileTests.test_specifiedPermissions  s     tyy$((F

#||BGGDII.t||<=%%''T5)T5)r   zCan't test reopen on Windowsc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     1 1T 1r   c                   \         P                  ! \        P                  ! V P                  V P
                  4      4      ;_uu_ 4       pVP                  R4       \        P                  P                  V P
                  R4      p\        P                  ! V P                  V4       VP                  4        VP                  R4       RRR4       \        V P                  4      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       \        X4      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       R#   + '       g   i     L; i  + '       g   i     La; i  + '       g   i     R# ; i)zs
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   r>   r   r   r?   r   r   r   renamereopenrA   rB   rC   )r    r   savePathrE   s   &   r   test_reopenLogFileTests.test_reopen  s     		488 DEEJJx ww||DHHj9HIIdii*KKMJJx  F $))__QVVXx0 (^^qQVVXx0 ^ FE _^^s%   A>E+!E%'!E8E"	%E5	8F		c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   "  s     0 0T 0r   c                    V P                  \        \        P                  V P                  R4      pV P                  VP                  \        P                  4       R# )zB
Specifying an invalid directory to L{LogFile} raises C{IOError}.
this_dir_does_not_existN)r/   IOErrorr   r>   r   rB   errnoENOENT)r    es   & r   test_nonExistentDir LogFileTests.test_nonExistentDir"  s@     W__dii1J
 	%,,/r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   +  s     1 1 1r   c                :   \         P                  P                  4       '       d   RRr!RpMRRr!Rp\        P                  ! WRR7      pV P                  VP                  4       V P                  VP                  V4       V P                  VP                  R4       R# )	zl
Opening a L{LogFile} which can be read and write but whose mode can't
be changed doesn't trigger an error.
NULrN   nullz/devz	/dev/nullr   r   N)
r   r   r   r   r>   r-   r.   rB   r   r   )r    r   	directoryexpectedPathr3   s   &    r   test_cantChangeFileMode$LogFileTests.test_cantChangeFileMode+  sy    
 %%''#R) L$f)&Lood5A		"<0%0r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   =  s     . .$ .r   c                   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       \        VP                   R2R4      ;_uu_ 4       pVP                  R4       RRR4       \        VP                   R2R4      ;_uu_ 4       pVP                  R4       RRR4       V P                  ^.VP                  4       4       R#   + '       g   i     Ln; i  + '       g   i     LF; i)zT
L{LogFile.listLogs} doesn't choke if it encounters a file with an
unexpected name.
rL   rt   r8   Nz	.bad-file)r   r>   r   r   r-   r.   rA   r   r?   rB   rX   r   s   &  r    test_listLogsWithBadlyNamedFiles-LogFileTests.test_listLogsWithBadlyNamedFiles=  s    
 oodii2		"SXXJb/3''2HHUO (SXXJi(#.."HHUO / 	!clln- ('..s   (C #C3 C0	3D	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   L  s     1 1t 1r   c                   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       \        ^ ^4       F@  p\        VP                   RV 2R4      ;_uu_ 4       pVP                  R4       RRR4       KB  	  V P                  ^^.VP                  4       4       R#   + '       g   i     Ky  ; i)zB
L{LogFile.listLogs} ignores log files which rotated suffix is 0.
.rt   r8   N)r   r>   r   r   r-   r.   rangerA   r   r?   rB   rX   )r    r3   ir   s   &   r   %test_listLogsIgnoresZeroSuffixedFiles2LogFileTests.test_listLogsIgnoresZeroSuffixedFilesL  s     oodii2		"q!A
!A3'-- .-  	!Q0 .--s   9B;;Cr   r   r   N)__name__
__module____qualname____firstlineno____doc__r!   r(   r4   rF   rY   re   rp   rv   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r   r   r	   r	      s    6'A54:1.)5V
2A.>;0=
$* G&&(*HI1 J1"01$.1 1r   r	   c                  2    ] tR tRtRtR R ltR R ltRtR# )	RiggedDailyLogFileiZ          c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   RiggedDailyLogFile.__annotate__]  s     & &4 &r   c                	n    \         P                  P                  V 4       V P                  4       V n        R # )N)r   DailyLogFile	_openFiletoDatelastDater   s   &r   r   RiggedDailyLogFile._openFile]  s#    &&t,r   c                    V ^8  d   QhRRRR/# )r   argsfloatr   ztuple[int, int, int]r   )r   s   "r   r   r   b  s     , ,E ,&: ,r   c                	    V'       d   \         P                  ! V!  R ,          # \         P                  ! V P                  4      R ,          # ):NrT   N)timegmtime_clock)r    r   s   &*r   r   RiggedDailyLogFile.toDateb  s1    ;;%b)){{4;;'++r   )r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   Z  s    F&
, ,r   r   c                      ] tR tRtRtR R ltR R ltR R ltR	 R
 ltR R lt	]
! ]P                  P                  4       R4      R R l4       tR R ltR R ltR R ltR R ltRtR# )DailyLogFileTestsih  z
Test rotating log file.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   DailyLogFileTests.__annotate__m  r   r   c                	    V P                  4       V n        \        P                  ! V P                  4       R V n        \        P
                  P                  V P                  V P                  4      V n        R# )ztestdaily.logNr   r   s   &r   r!   DailyLogFileTests.setUpm  sD    ;;=
DHH#	GGLL4995	r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   s  s     5 5d 5r   c                   \         P                  ! \        V P                  V P                  4      4      ;_uu_ 4       pVP                  R4       VP                  R4       VP                  4        VP                  R4       RRR4       \        V P                  4      ;_uu_ 4       pV P                  VP                  4       R4       RRR4       R#   + '       g   i     LX; i  + '       g   i     R# ; i)z?
A daily log file can be written to like an ordinary log file.
r8   r9   r:   Nr;   )r<   r=   r   r   r   r?   r@   rA   r   rB   rC   rD   s   &  r   rF   DailyLogFileTests.test_writings  s      2499dhh GHHCIIeIIeIIKIIf	 I $))__QVVX|4 _ IH __s   AC&!C$C!	$C5	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     2 2t 2r   c                   \        V P                  V P                  4      pV P                  VP                  4       \        ^4       Uu. uF2  q P                  R,           VP                  VR,          4      ,           NK4  	  ppRVn        VP                  R4       RVn        VP                  R4       RVn        VP                  R4       V P                  \        P                  P                  V^ ,          4      4       V P                  \        P                  P                  V^,          4      4       RVn        VP                  R4       V P                  \        P                  P                  V^ ,          4      4       V P                  \        P                  P                  V^,          4      4       V P                  \        P                  P                  V^,          4      4       R	Vn        VP                  R
4       V P                  \        P                  P                  V^,          4      4       R# u upi )z
Daily log files rotate daily.
r   Q r   r8   i  rK   i  rN   i rP   NrR   )r   r   r   r-   r.   r   r   suffixr   r?   rU   r   r'   rV   )r    r3   daydayss   &   r   rY   DailyLogFileTests.test_rotation  st    !DHH5		"GLQxPxS3::cEk#:::xP 
		%
		)
		(tAw/0Q01
		"tAw/0tAw/0Q01
		#Q01% Qs   	8H;c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     . .T .r   c                   . ROp\        V P                  V P                  4      pV P                  VP                  4       V F  pVP                  V4       K  	  VP                  4        VP                  R4      pV P                  VP                  4       V P                  WP                  4       4       V P                  \        VP                  R4       RVn        VP	                  4        VP                  4        VP                  ^ 4      pV P                  VP                  4       V P                  WP                  4       4       R# )z8
Test retrieving log files with L{DailyLogFile.getLog}.
r   r   iQ N)z1
z2
z3
)r   r   r   r-   r.   r?   r@   rl   rB   rk   r/   rm   r   rW   )r    datar3   drs   &    r   test_getLogDailyLogFileTests.test_getLog  s     % DHH5		"AIIaL 		 JJsO {{}- 	*cjj%8
		

JJqM {{}-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     2 2$ 2r   c                   \        V P                  V P                  4      pV P                  VP                  4       VP
                   RVP                  VP                  4       2p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       VP                  pVP                  4        V P                  WAP                  4       R#   + '       g   i     LI; i)z]
L{DailyLogFile.rotate} doesn't do anything if they new log file already
exists on the disk.
r   rt   r8   N)r   r   r   r-   r.   r   r   r   rA   r?   r`   rW   rB   )r    r3   newFilePathr   previousFiles   &    r   test_rotateAlreadyExists*DailyLogFileTests.test_rotateAlreadyExists  s    
 !DHH5		" 
!CJJs||$<#=>+s##rHHUO $yy

yy1	 $#s   :CC	zVMaking read-only directories on Windows is too complex for this test to reasonably do.c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     2 2T 2r   c                   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       \        P                  ! VP                  R4       V P	                  \        P                  VP                  R4       VP                  pVP                  4        V P                  W!P                  4       R# )zk
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   r`   rW   rB   r    r3   r  s   &  r   #test_rotatePermissionDirectoryNotOk5DailyLogFileTests.test_rotatePermissionDirectoryNotOk  s|     ""499dhh7		"
&#--7yy

yy1r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     2 2 2r   c                B   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       \        P                  ! VP                  R4       VP                  pVP                  4        V P                  W!P                  4       R# )zQ
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   r`   rW   rB   r	  s   &  r   test_rotatePermissionFileNotOk0DailyLogFileTests.test_rotatePermissionFileNotOk  sd    
 ""499dhh7		"
5!yy

yy1r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     	> 	>T 	>r   c                    \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       \        P                  ! R4      pV P                  RVP                  V4      4       R# )zf
Test that L{DailyLogFile.toDate} converts its timestamp argument to a
time tuple (year, month, day).
N)	  rS   rS   r   r   r   r   r   r   )r  rS   rS   )
r   r   r   r   r-   r.   r   mktimerB   r   )r    r3   	timestamps   &  r   test_toDateDailyLogFileTests.test_toDate  sV    
 ""499dhh7		"KK >?	szz)'<=r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     - - -r   c                  a  R V 3R llp\         P                  ! S P                  S P                  4      pS P	                  VP
                  4       S P                  \        RV4       VP                  4       pS P                  . ROV4       R# )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.
c                    V ^8  d   QhRRRR/# )r   r   objectr   z	list[int]r   )r   s   "r   r   ?DailyLogFileTests.test_toDateDefaultToday.<locals>.__annotate__  s     	% 	%& 	%Y 	%r   c                 R   < SP                  RV 4       \        \        ^ ^	4      4      # )r   r   )rB   listr   )r   r    s   *r   mock_localtimeADailyLogFileTests.test_toDateDefaultToday.<locals>.mock_localtime  s$    R&a$$r   	localtimeN)r   rS   r   )
r   r   r   r   r-   r.   patchr   r   rB   )r    r  r3   logDates   f   r   test_toDateDefaultToday)DailyLogFileTests.test_toDateDefaultToday  sd    	% 	% ""499dhh7		"

4n5**,G,r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   
  s     ( (T (r   c                   \         P                  ! V P                  V P                  4      pV P	                  VP
                  4       Rp\        P                  ! VR,           4      pVP                  V4      pV P                  W$4       R# )zK
Test that L{DailyLogFile.toDate} uses its arguments to create a new
date.
N)i  
      )r   r   r   r   r   r   )
r   r   r   r   r-   r.   r   r  r   rB   )r    r3   datesecondsr"  s   &    r   #test_toDateUsesArgumentsToMakeADate5DailyLogFileTests.test_toDateUsesArgumentsToMakeADate
  sa    
 ""499dhh7		"++dXo.**W%'r   r   N)r   r   r   r   r   r!   rF   rY   r   r  r   r   r   r   r
  r  r  r#  r+  r   r   r   r   r   r   h  si    6524.62" ""$	!
2
22	>-0( (r   r   )
__future__r   r<   r   r   r{   r   unittestr   twisted.pythonr   r   twisted.trial.unittestr   r	   r   r   r   r   r   r   <module>r1     sQ    #   	    + +G18 G1T
,-- ,n( n(r   