Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyc

ó
ê=Nc@s¥ddlZddlZddlZddlZddlmZddlmZmZdej	fd„ƒYZ
dejfd„ƒYZdej	fd	„ƒYZ
dS(
iÿÿÿÿN(tunittest(tlogfiletruntimetLogFileTestCasecBs§eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„Zejjƒrœde_nd„ZRS(s%
    Test the rotating log file.
    cCsJ|jƒ|_tj|jƒd|_tjj|j|jƒ|_dS(Nstest.log(tmktemptdirtostmakedirstnametpathtjoin(tself((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pytsetUps	cCsBtj|jdƒtjj|jƒr>tj|jdƒndS(sž
        Restore back write rights on created paths: if tests modified the
        rights, that will allow the paths to be removed easily afterwards.
        iÿN(RtchmodRR	texists(R((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttearDownscCs‰tj|j|jƒ}|jdƒ|jdƒ|jƒ|jdƒ|jƒt|jdƒ}|j	|j
ƒdƒ|jƒdS(Nt123t456t7890trt
1234567890(RtLogFileRRtwritetflushtclosetopenR	tassertEqualtread(Rtlogtf((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttestWriting s




cCsštj|j|jddƒ}|jdƒ|jdƒ|jdƒ|jtjjd|jƒƒ|jtjjd|jƒƒ|jd	ƒ|jtjjd|jƒƒ|jtjjd|jƒƒ|jtjjd
|jƒƒ|jdƒ|jtjjd
|jƒƒ|j	ƒ|jtjjd
|jƒƒ|jtjjd|jƒƒ|j
ƒ|j|jƒd
ddgƒdS(NtrotateLengthi
Rt4567890t1is%s.1s%s.2ts%s.3t3s%s.4iiit11111111111(
RRRRRtassert_RR	RtrotateRRtlistLogs(RR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttestRotation,s"


 !
  !
!
 !
cCsïtj|j|jƒ}|jdƒ|jƒtj|j|jƒ}|j|jdƒ|j|jj	ƒ|jƒ|jdƒ|j|jdƒ|j|jj	ƒ|jƒ|j}|j
ddƒ|j|jƒdƒ|jƒdS(Nt
0123456789i
tabci
it
0123456789abc(RRRRRRRtsizet_filettelltseekR(RRR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyt
testAppendEs


	cCstj|j|jƒ}|jdƒ|jdƒ|jƒ|jdƒ|jƒ|j|jƒdgƒ|j	ƒ}|j
jdƒ|j|jƒdgƒ|j|jƒgƒ|j
ƒ|jdƒ}|j|jƒddgƒ|j|jƒgƒ|j
ƒ|jt|jdƒ|jt|jdƒ|jƒ|j|jƒddgƒ|jdƒ}|j
jdƒ|j|jƒdgƒ|j|jƒgƒ|j
ƒ|jdƒ}|j|jƒddgƒ|j|jƒgƒ|j
ƒdS(Nsabc
sdef
sghi
iiiR!(RRRRRR&RRR't
getCurrentLogR-R/t	readLinesRtgetLogtassertRaisest
ValueErrort	TypeError(RRtreader((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyt
testLogReaderUs:








cCsšt|jdƒjƒ}tj|jdƒtj|jƒtj}tj|j	|j
ƒ}|jdƒ|jƒ|j
|tj|jƒtjƒdS(sH
        Check rotated files have same permissions as original.
        twiÇR*N(RR	RRR
tstattST_MODERRRRRR&R(RRtmodeR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttestModePreservationzs

cCsùtj|j|jƒ}|jdƒtj|jdƒy%ttjj	|jdƒdƒ}Wnt
tfk
rvnX|jƒdS|j
ƒ|jdƒ|jƒ|j}|j|jƒdƒ|jddƒ|j|jƒd	ƒ|jƒdS(
sH
        Check it keeps working when permission on dir changes.
        R*imtxxxR9Ntdefiitabcdef(RRRRRRR
RR	R
tOSErrortIOErrorRR&RR-RR.R/R(RRR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_noPermission‡s"
%



	cCs0tj|j|jddddƒ}|jdƒ|jdƒ|jtjjd|jƒƒ|jdƒ|jtjjd
|jƒƒ|jdƒ|jtjjd|jƒƒ|j	t
d|jƒjƒdƒ|jdƒ|j	t
d|jƒjƒdƒ|jtjjd|jƒƒdS(sl
        Test it respect the limit on the number of files when maxRotatedFiles
        is not None.
        Ri
tmaxRotatedFilesiR!it2s%s.1R#s%s.2t4s%s.3t5s%s.4NR$t22222222222t33333333333t44444444444R$t55555555555RH(RRRRRt
failUnlessRR	RRtfileR(RR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_maxNumberOfLog§s	

 
 
 #
#cCs§tj|j|jdddƒ}tjj|jdddƒ}|j|j|jƒ|jtjj|jƒ|jƒ|j|j	|j	ƒ|j|j
|j
ƒdS(s/
        Test the fromFullPath method.
        i
tdefaultModeiÿN(RRRRtfromFullPathR	RRtabspathRRO(Rtlog1tlog2((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_fromFullPath½s!"cCs™t|jdƒ}tj|jdƒtjtj|jƒtjƒ}|jƒtj	|j
|jƒ}|jtjtj|jƒtjƒ|ƒdS(sx
        Test the default permission of the log file: if the file exist, it
        should keep the permission.
        R9iÇN(
RMR	RR
R:tS_IMODER;RRRRRR(RRtcurrentModeRR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_defaultPermissionsÈs"
%cCsvtj|j|jddƒ}tjtj|jƒtjƒ}t	j
jƒrb|j|dƒn|j|dƒdS(sG
        Test specifying the permissions used on the log file.
        ROi6i$N(
RRRRR:RURR	R;Rtplatformt	isWindowsR(RRRR<((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_specifiedPermissionsÖs
"cCsÖtj|j|jƒ}|jdƒtjj|jdƒ}tj|j|ƒ|j	ƒ|jdƒ|j
ƒt|jdƒ}|j|j
ƒdƒ|j
ƒt|dƒ}|j|j
ƒdƒ|j
ƒdS(s‹
        L{logfile.LogFile.reopen} allows to rename the currently used file and
        make L{logfile.LogFile} create a new file.
        thello1ssave.logthello2RN(RRRRRRR	R
trenametreopenRRRR(RRRtsavePathR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_reopenãs




sCan't test reopen on WindowscCs8|jttj|jdƒ}|j|jtjƒdS(sR
        Specifying an invalid directory to L{LogFile} raises C{IOError}.
        tthis_dir_does_not_existN(R4RBRRRRterrnotENOENT(Rte((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyttest_nonExistentDirûs(t__name__t
__module__t__doc__RRRR(R0R8R=RCRNRTRWRZR`RRXRYtskipRe(((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyR
s"		
				%	
	 				
	tRiggedDailyLogFilecBs eZdZd„Zd„ZRS(gcCs#tjj|ƒ|jƒ|_dS(N(RtDailyLogFilet	_openFilettoDatetlastDate(R((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyRlscGs+|rtj|Œd Stj|jƒd S(Ni(ttimetgmtimet_clock(Rtargs((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyRm
s(RfRgRqRlRm(((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyRjs	tDailyLogFileTestCasecBs)eZdZd„Zd„Zd„ZRS(s!
    Test rotating log file.
    cCsJ|jƒ|_tj|jƒd|_tjj|j|jƒ|_dS(Ns
testdaily.log(RRRRRR	R
(R((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyRs	cCs†t|j|jƒ}|jdƒ|jdƒ|jƒ|jdƒ|jƒt|jdƒ}|j|j	ƒdƒ|jƒdS(NRRRRR(
RjRRRRRRR	RR(RRR((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyRs




cCsot|j|jƒ}gtdƒD]$}|jd|j|dƒ^q"}d|_|jdƒd|_|jdƒd|_|jdƒ|jt	jj
|d
ƒƒ|jt	jj
|dƒƒd|_|jd
ƒ|jt	jj
|d
ƒƒ|jt	jj
|dƒƒ|jt	jj
|dƒƒd|_|jdƒ|jt	jj
|dƒƒdS(Nit.i€QgRiÀ¨R R!iiii£R"iiôR#R$(RjRRtrangeR	tsuffixRqRR%RR(RRtdaytdays((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyR(*s$7	
	
	
	
	
(RfRgRhRRR((((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyRss		(RRoR:Rbt
twisted.trialRttwisted.pythonRRtTestCaseRRkRjRs(((s=/usr/lib/python2.7/dist-packages/twisted/test/test_logfile.pyt<module>s
0û