��Qc@s�dZdZddlZddlZddlZddlZddlmZddlZddl m
Z
mZmZm
Z
mZddlmZmZddlmZddlmZmZy"ddlZddlZeZWnek
r�eZnXyddlZeZWnek
r-ed �ZnXyddlZWnek
rWe ZnXd
�Z!dej"ej#ej$fd��YZ%d
�Z&e'dkr�ee&��ndS(s!Tests for distutils.archive_util.s$Id$i�N(t
splitdrive(tcheck_archive_formatstmake_tarballtmake_zipfiletmake_archivetARCHIVE_FORMATS(tfind_executabletspawn(tsupport(tcheck_warningstrun_unittesttzipcCs@tjjrtSy|jtj��Wntk
r;tSXtS(sF
Return True if the filename can be saved in the file system.
( tostpathtsupports_unicode_filenamestTruetencodetsystgetfilesystemencodingtUnicodeEncodeErrortFalse(tfilename((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt
can_fs_encode&s
tArchiveUtilTestCasecBs�eZejed�d��Zd�Zd�Zd�Zejed�eje d�ofe d�d�d ���Z
eje d
�d�d��Zejed�ejed
�d���Z
d�Zd�Zejed�d��Zejed�ejed�d���Zd�Zejed�d��Zejed�ejed�d�d���Zejed�ejed�d�d���ZRS(s
requires zlibcCs|jd�dS(Ntarchive(t
_make_tarball(tself((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_make_tarball7scCs�|j�}|j|dgd�|j|dgd�tjtjj|d��|j|ddgd�|j�}tjt|�dt|�dkd�tjj||�}tj �}tj
|�ztt|�dd �Wdtj
|�X|d
}|jtjj
|��tjj||�}tj �}tj
|�z!tt|�dd dd�Wdtj
|�X|d}|jtjj
|��dS(
Ntfile1txxxtfile2tsubtfile3is)source and target should be on same driveit.s.tar.gztcompresss.tar(tmkdtempt
write_fileRtmkdirR
tjointunittestt
skipUnlessRtgetcwdtchdirRt
assertTruetexiststNone(Rttarget_namettmpdirttmpdir2t base_nametold_dirttarball((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyR;s0#
!
cCsEtj|�}z$|j�}|j�t|�SWd|j�XdS(N(ttarfiletopentgetnamestsortttupletclose(RR
ttartnames((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt_tarinfo`s
cCs�|j�}tjj|d�}tj|�|j|dgd�|j|dgd�tjtjj|d��|j|ddgd�tjtjj|d��|j�}tjj|d�}|||fS( NtdistRRRRR tsub2R(R#RR
R&R%R$(RR/R=R0R1((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt
_create_filesis
s
Requires zlibR:tgzipsNeed the tar command to runc Cs"|j�\}}}tj�}tj|�zt|d�Wdtj|�X|d}|jtjj|��tjj|d�}ddddg}dddg}tj�}tj|�zt |�t |�Wdtj|�X|jtjj|��|j
|j|�|j|��tjj|d �}tj�}tj|�zt|dd
d�Wdtj|�X|d}|jtjj|��tjj|d �}tj�}tj|�zt|dd
ddt
�Wdtj|�X|d}|jtjj|��dS(
NR=s.tar.gzsarchive2.tar.gzR:s-cfsarchive2.tarR@s-f9RR"s.tartdry_run(R?RR)R*RR+R
R,R&RtassertEqualR<R-R( RR/R0R1R2R3ttarball2ttar_cmdtgzip_cmd((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_tarfile_vs_tarwsF
"
R"s The compress program is requiredcCs[|j�\}}}tj�}tj|�z6t��}tjd�t|ddd�WdQXWdtj|�X|d}|jtj j
|��|jt|j�d�tj
|�tj�}tj|�z<t��}tjd�t|ddddt�WdQXWdtj|�X|jtj j
|��|jt|j�d�dS(NtalwaysR=R"s.tar.ZiRA(R?RR)R*R twarningstsimplefilterRR+R
R,RBtlentremoveR(RR/R0R1R2twR3((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_compress_deprecated�s,
sNeed zip support to runcCst|j�}|j|dgd�|j|dgd�|j�}tjj|d�}t||�|d}dS(NRRRRs.zip(R#R$RR
R&R(RR/R0R1R3((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_make_zipfile�s
cCs?|jtdddg�d�|jtddg�d�dS(NtgztarRR(RBRR-(R((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_check_archive_formats�scCs;|j�}tjj|d�}|jtt|d�dS(NRR(R#RR
R&tassertRaisest
ValueErrorR(RR/R1((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_make_archive�sc CsItr/tjd�d}tjd�d}n
d}}|j�\}}}tjj|j �d�}t
|d||d|d|�}|jtjj|��t
|d||�}|jtjj|��t
|d||d|d|�}|jtjj|��t
|d||dddd �}|jtjj|��dS(
NitrootRRtownertgroupR:t kjhkjhkjgtoihohoh(
tUID_GID_SUPPORTtgrptgetgrgidtpwdtgetpwuidR?RR
R&R#RR+R,(RRVRUtbase_dirtroot_dirR1tres((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_make_archive_owner_group�s"
sRequires grp and pwd supportc
Cs|j�\}}}tj�}tj|�tjd�d}tjd�d}z%t|dddd|d|�}Wdtj|�X|j
tjj|��t
j|�}zAx:|j�D],} |j| jd�|j| jd�q�WWd|j�XdS(NiR=R"RURV(R?RR)R*RZR[R\R]RR-R+R
R,R4R5t
getmembersRBtuidtgidR9(
RR/R0R1R2RVRUtarchive_nameRtmember((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_tarfile_root_owners
cCsxtj�}d�}|gdftd<zAytddd|j��WnnX|jtj�|�Wdtd=XdS(Nc_s
t��dS(N(tRuntimeError(targstkw((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt_breaksssxxx fileRR_(RR)RRR#RB(Rtcurrent_dirRk((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_make_archive_cwds cCs|jd�dS(sG
Mirror test_make_tarball, except filename is unicode.
uarchiveN(R(R((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyttest_make_tarball_unicode)suårchivs'File system cannot handle this filenamecCs|jd�dS(sm
Mirror test_make_tarball, except filename is unicode and contains
latin characters.
uårchivN(R(R((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt test_make_tarball_unicode_latin10suのアーカイブcCs|jd�dS(s�
Mirror test_make_tarball, except filename is unicode and contains
characters outside the latin charset.
uのアーカイブN(R(R((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt"test_make_tarball_unicode_extended:s(t__name__t
__module__R'R(tzlibRRR<R?RRFRMtZIP_SUPPORTRNRPRSRaRYRgRmRnRRoRp(((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyR3s0 % 4 cCs
tjt�S(N(R't makeSuiteR(((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt
test_suiteDst__main__((t__doc__t__revision__R'RRR4tos.pathRRHtdistutils.archive_utilRRRRRtdistutils.spawnRRtdistutils.testsRttest.test_supportR R
RZR\RRYtImportErrorRtzipfileRtRsR-RtTempdirManagertLoggingSilencertTestCaseRRvRq(((s7/sys/lib/python2.7/distutils/tests/test_archive_util.pyt<module>sD(
�
|