{G_Tc@sxddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ejddedddeeedrddlZd Znd ZejejkZeed Zejd2krdZndZde jfdYZgZdefdYZejedefdYZejedefdYZ eje defdYZ!eje!defdYZ"eje"e j#dZ$dZ%defdYZ&eje&d efd!YZ'eje'd"efd#YZ(eje(d$efd%YZ)eje)d&efd'YZ*eje*d(efd)YZ+eje+d*efd+YZ,eje,d,efd-YZ-eje-d.efd/YZ.ej/ej0k rUeje.nd0Z1ed1krte1ndS(3iN(t test_supporttignoretcategorytmessagetmktemptmoduletstatiitspawnltopenbsd3topenbsd4i0idtTCcBs,eZejdZddZdZRS(s[a-zA-Z0-9_-]{6}$cCsA|dkrtj}n|jd||d|dfdS(Ns%s raised %s: %sii(tNonetsystexc_infotfail(tselftwhattei((s./usr/local/lib/python2.7/test/test_tempfile.pytfailOnException-s c Cstjj|\}}|t| }|t|t|}|jtjj|tjj|d||f|j||d||f|j||d||f|t|t|t|!}|j|jj|d|dS(Nsfile '%s' not in directory '%s's"file '%s' does not begin with '%s's file '%s' does not end with '%s's6random string '%s' does not match /^[a-zA-Z0-9_-]{6}$/( tostpathtsplittlent assertEqualtabspatht assertTruet str_checktmatch( Rtnametdirtpretsuftndirtnbasetnpretnsuf((s./usr/local/lib/python2.7/test/test_tempfile.pyt nameCheck2s$  #N(t__name__t __module__tretcompileRR RR$(((s./usr/local/lib/python2.7/test/test_tempfile.pyR )s t test_exportscBseZdZRS(cCstj}i dd6dd6dd6dd6dd6dd6dd6dd 6dd 6dd 6dd 6}g}x:|D]2}|d dkri||kri|j|qiqiW|jt|d kd|dS(NitNamedTemporaryFilet TemporaryFiletmkstemptmkdtempRtTMP_MAXt gettempprefixt gettempdirttempdirttemplatetSpooledTemporaryFileit_sunexpected keys: %s(ttempfilet__dict__tappendRR(Rtdicttexpectedtunexptkey((s./usr/local/lib/python2.7/test/test_tempfile.pyR)Gs&   (R%R&R)(((s./usr/local/lib/python2.7/test/test_tempfile.pyR)Fsttest__RandomNameSequencecBsVeZdZdZdZdZdZeje e dddZ RS(s6Test the internal iterator object _RandomNameSequence.cCstj|_dS(N(R5t_RandomNameSequencetr(R((s./usr/local/lib/python2.7/test/test_tempfile.pytsetUpfscCs)|jj}|j|ddddS(Nt(R>tnextR$(Rts((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_get_six_char_striscCsfi}|j}xPttD]B}|j}|j|ddd|j||d||txranget TEST_FILESRAR$t assertNotIn(RR8R>tiRB((s./usr/local/lib/python2.7/test/test_tempfile.pyt test_manyns  cCsYd}|j}y/x(|D] }|d7}|dkrPqqWWn|jdnXdS(Niiit iteration(R>R(RRGR>RB((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_supports_iterys     tforks!os.fork is required for this testcCstj\}}d}ztj}|sytj|tj|t|jjdtj|tj dnt|j}tj |t |j d}Wd|rytj |tjWqtk rqXntj|tj|X|j||dS(Ntasciii(RtpipeR RKtclosetwriteRAR>tencodet_exittreadRtdecodetkilltsignaltSIGKILLtEnvironmentErrortassertNotEqual(Rtread_fdtwrite_fdtpidt parent_valuet child_value((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_process_awarenesss&  " %  ( R%R&t__doc__R?RCRHRJtunittestt skipUnlessthasattrRR^(((s./usr/local/lib/python2.7/test/test_tempfile.pyR<cs   ttest__candidate_tempdir_listcBs eZdZdZdZRS(s3Test the internal function _candidate_tempdir_list.cCsJtj}|jt|dkx|D]}|j|tq,WdS(Ni(R5t_candidate_tempdir_listt assertFalseRtassertIsInstancet basestring(Rtcandtc((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_nonempty_lists  c Cstj}x<dD]4}tj|}|stjj|||s(RnRR5(R((Rs./usr/local/lib/python2.7/test/test_tempfile.pyt_mock_candidate_namess ttest__mkstemp_innercBseZdZdddYZdddddZdZdZdZe j e d d Z e j e d d Ze j ed dZdZdZdZRS(s*Test the internal function _mkstemp_inner.t mkstempedcBsGeZejZejZejZ ej Z dZ dZ dZRS(cCsC|r|j}n |j}tj||||\|_|_dS(N(t_bflagst_tflagsR5t_mkstemp_innertfdR(RRRRtbintflags((s./usr/local/lib/python2.7/test/test_tempfile.pyt__init__+s  cCstj|j|dS(N(RROR(Rtstr((s./usr/local/lib/python2.7/test/test_tempfile.pyRO1scCs$|j|j|j|jdS(N(t_closeRt_unlinkR(R((s./usr/local/lib/python2.7/test/test_tempfile.pyt__del__4s(R%R&R5t_bin_openflagsRt_text_openflagsRRRNRtunlinkRRROR(((s./usr/local/lib/python2.7/test/test_tempfile.pyR%s      R@icCsk|dkrtj}ny|j||||}Wn|jdnX|j|j||||S(NR(R R5R0RRR$R(RRRRRtfile((s./usr/local/lib/python2.7/test/test_tempfile.pyt do_create8s cCs|jjd|jddjd|jddjd|jddddjd|jddddjddS(NtblatRRRRtaas.txt(RRO(R((s./usr/local/lib/python2.7/test/test_tempfile.pyt test_basicCs cCs7tt}x$|D]}|jdd||tj}z|jd|jdWdtj|XdS(NRR(R5R-RRORtrmdir(RR((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_choose_directoryQs sos.stat not availablecCsj|j}tjtj|jj}d}tjdkrV|d?}|d }n|j||dS( Nitwin32tos2emxiiii@(swin32sos2emxi iI( RRtS_IMODERRtst_modeR tplatformR(RRtmodeR9tuser((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_file_modeYs   sos.spawnl not availablecCstjrd}nd}|j}d|j}y t}Wntk r[tjd}nXtj j tj j tj j |d}tj d krdtj}d|}n tj}tjtjtj||||}|j|dkd| |j|dkd |dS( Ntvtqs%distf_inherit_check.pyRs"%s"s$child process caught fatal signal %ds child process reports failure %d(swin32(RntverboseRRt__file__t NameErrorR targvRRtjoinRyRRt executableRtP_WAITRe(RRRRtmettestert decoratedtretval((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_noinheritgs&      $    $ stext mode not availablecCs|jddjddS(NRisblat (RRO(R((s./usr/local/lib/python2.7/test/test_tempfile.pyt test_textmodescCs"tjtjtjdtjS(NR@(R5RR0R2R(R((s./usr/local/lib/python2.7/test/test_tempfile.pytdefault_mkstemp_innersc Csttdddo|j\}}tj||j|jd|j\}}tj||j|jdWdQXWdQXdS(Ntaaatbbb(RRRRRNRtendswith(Rtfd1tname1tfd2tname2((s./usr/local/lib/python2.7/test/test_tempfile.pyt!test_collision_with_existing_files   c Cstutddd\tj}|j|jd|j\}}tj||j|jdWdQXWdQXdS(NRR( RRR5R-RRRRRN(RRRR((s./usr/local/lib/python2.7/test/test_tempfile.pyt&test_collision_with_existing_directorys   (N(R%R&R_RR RRRRR`Rathas_statRt has_spawnlRt has_textmodeRRRR(((s./usr/local/lib/python2.7/test/test_tempfile.pyR"s   %  ttest_gettempprefixcBs eZdZdZdZRS(sTest gettempprefix().cCs9tj}|j|t|jt|dkdS(Ni(R5R/RfRgRR(Rtp((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_sane_templates cCstjd}tjdd}zjtjj||}y tj|tjtjB}Wn|j dnXtj |tj |Wdtj |XdS(Ns xxxxxx.xxxtprefixR@sos.open( R5R/R-RRRRtO_RDWRtO_CREATRRNRR(RRtdR((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_usable_templates  (R%R&R_RR(((s./usr/local/lib/python2.7/test/test_tempfile.pyRs ttest_gettempdircBs)eZdZdZdZdZRS(sTest gettempdir().cCs_tj}|jtjj|p0|tjkd||jtjj|d|dS(Ns%s is not an absolute paths%s is not a directory(R5R0RRRtisabsRvtisdir(RR((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_directory_existss  $ cCsLy'tj}|jd|jWn|jdtjnXdS(NRscreate file in %s(R5R*RORNRR0(RR((s./usr/local/lib/python2.7/test/test_tempfile.pyttest_directory_writables   cCs/tj}tj}|j||kdS(N(R5R0R(RRR((s./usr/local/lib/python2.7/test/test_tempfile.pyRs  (R%R&R_RRR(((s./usr/local/lib/python2.7/test/test_tempfile.pyRs t test_mkstempcBs2eZdZddddZdZdZRS(sTest mkstemp().R@c Cs|dkrtj}nyotjd|d|d|\}}tjj|\}}tjj|}|j||d||fWn|j dnXz|j ||||Wdtj |tj |XdS(NRRtsuffixs+Directory '%s' incorrectly returned as '%s'R,( R R5R0R,RRRRRRR$RNR( RRRRRRR R!tadir((s./usr/local/lib/python2.7/test/test_tempfile.pyRs $  cCsj|j|jdd|jdd|jdddd|jdddd|jdddS( NRRRRRs.txtRt.(R(R((s./usr/local/lib/python2.7/test/test_tempfile.pyR s  cCs5tj}z|jd|Wdtj|XdS(NR(R5R-RRR(RR((s./usr/local/lib/python2.7/test/test_tempfile.pyRs N(R%R&R_R RRR(((s./usr/local/lib/python2.7/test/test_tempfile.pyRs t test_mkdtempcBsheZdZd dddZdZdZdZej e ddZ dZ d Z RS( sTest mkdtemp().R@cCs|dkrtj}ny"tjd|d|d|}Wn|jdnXy|j|||||SWntj|nXdS(NRRRR-(R R5R0R-RR$RR(RRRRR((s./usr/local/lib/python2.7/test/test_tempfile.pyR$s " cCstj|jtj|jddtj|jddtj|jddddtj|jdddddS(NRRRRRs.txt(RRR(R((s./usr/local/lib/python2.7/test/test_tempfile.pyR3s cCsott}z+x$|D]}|jdd||tj}ztj|jd|Wdtj|XdS(NR(R5R-RRR(RR((s./usr/local/lib/python2.7/test/test_tempfile.pyRFs sos.stat not availablecCs|j}zetjtj|j}|dM}d}tjd kr`|d?}|d }n|j||Wdtj|XdS( NiiRRiiii@(swin32sos2emxi iI( RRRRRR RRR(RRRR9R((s./usr/local/lib/python2.7/test/test_tempfile.pyt test_modeNs    c Cstutddd\tjdt}|j|j|jjdtj }|j|jdWdQXWdQXdS(NRRtdelete( RRR5R*tFalseRNRRRR-(RRR((s./usr/local/lib/python2.7/test/test_tempfile.pyR`s   c CsqtbtdddItj}|j|jdtj}|j|jdWdQXWdQXdS(NRR(RRR5R-RR(Rtdir1tdir2((s./usr/local/lib/python2.7/test/test_tempfile.pyRks    N(R%R&R_R RRRRR`RaRRRR(((s./usr/local/lib/python2.7/test/test_tempfile.pyR!s   t test_mktempcBsTeZdZdZdZdd dYZdddZdZdZRS( sTest mktemp().cCstj|_dS(N(R5R-R(R((s./usr/local/lib/python2.7/test/test_tempfile.pyR?}scCs)|jr%tj|jd|_ndS(N(RRRR (R((s./usr/local/lib/python2.7/test/test_tempfile.pyttearDowns tmktempedcBs,eZejZejZdZdZ RS(cCsGtjd|d|d||_tjtj|j|jddS(NRRRi(R5RRRRNRR(RRRR((s./usr/local/lib/python2.7/test/test_tempfile.pyRs!cCs|j|jdS(N(RR(R((s./usr/local/lib/python2.7/test/test_tempfile.pyRs( R%R&RRRR5RRRR(((s./usr/local/lib/python2.7/test/test_tempfile.pyRs   R@cCsSy|j|j||}Wn|jdnX|j|j|j|||S(NR(RRRR$R(RRRR((s./usr/local/lib/python2.7/test/test_tempfile.pyRs cCsZ|j|jdd|jdd|jdddd|jdddddS(NRRRRRs.txt(R(R((s./usr/local/lib/python2.7/test/test_tempfile.pyRs  cCs7tt}x$|D]}|jdd||sv                 B ' *      & T 9 c  *