HEX
Server: LiteSpeed
System: Linux s3.sitechai.com 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: workzeni (2217)
PHP: 8.1.32
Disabled: mail, show_source, system, shell_exec, passthru, exec, eval, shell
Upload Files
File: //usr/lib64/python3.6/site-packages/borg/testsuite/__pycache__/helpers.cpython-36.opt-1.pyc
3

y��bα�	@s*ddlZddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZddlZddlmZddlmZddlmZdd	lmZmZmZmZmZmZmZdd
lmZmZddlmZmZm Z ddlm!Z!m"Z"m#Z#m$Z$m%Z%dd
lm&Z&ddlm'Z'm(Z(ddlm)Z)m*Z*m+Z+m,Z,ddlm-Z-m.Z.m/Z/m0Z0ddlm1Z1m2Z2m3Z3ddlm4Z4m5Z5ddlm6Z6ddlm7Z7ddlm8Z8m9Z9m:Z:ddlm;Z;ddlm<Z<ddlm=Z=ddlm>Z>m?Z?Gdd�de>�Z@dd�ZAGdd �d �ZBGd!d"�d"�ZCGd#d$�d$e>�ZDd%d&�ZEGd'd(�d(e>�ZFGd)d*�d*�ZGGd+d,�d,e>�ZHGd-d.�d.e>�ZIGd/d0�d0e>�ZJGd1d2�d2e>�ZKGd3d4�d4e>�ZLd5d6�ZMd7d8�ZNd9d:�ZOd;d<�ZPd=d>�ZQd?d@�ZRdAdB�ZSdCdD�ZTejUjVdEd��dQdR��ZWejUjVdSd��dYdZ��ZXd[d\�ZYGd]d^�d^�ZZd_d`�Z[dadb�Z\dcdd�Z]dedf�Z^dgdh�Z_didj�Z`dkdl�Zadmdn�Zbdodp�Zcdqdr�Zddsdt�Zedudv�Zfdwdx�Zgdydz�Zhd{d|�Zid}d~�Zjdd��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��ZrejUjser�d�d��d�d���ZtejUjser�d�d��d�d���Zud�d��ZvGd�d��d��Zwd�d��Zxd�d��Zyd�d��ZzdS)��N)�ArgumentTypeError)�datetime�timezone�	timedelta)�mktime�strptime�sleep�)�platform)�Location)�Buffer)�partial_format�format_file_size�parse_file_size�format_timedelta�format_line�PlaceholderError�replace_placeholders)�make_path_safe�clean_lines)�interval�prune_within�prune_split)�get_base_dir�
get_cache_dir�get_keys_dir�get_security_dir�get_config_dir)�is_slow_msgpack)�msgpack�msgpack_fallback)�yes�TRUISH�FALSISH�
DEFAULTISH)�
StableDict�
int_to_bigint�
bigint_to_int�
bin_to_hex)�parse_timestamp�ChunkIteratorFileWrapper�
ChunkerParams)�ProgressIndicatorPercent�ProgressIndicatorEndless)�swidth_slice)�chunkit)�safe_ns�safe_s�SUPPORT_32BIT_PLATFORMS)�popen_with_error_handling)�	dash_open)�safe_unlink�)�BaseTestCase�
FakeInputsc@seZdZdd�ZdS)�BigIntTestCasecCs�|jtd�d�|jtd	�d�|jtd�d�|jtd�d�|jtd�d�|jttdd��dd�|jttdd��dd�dS)Nrr	�?r6s	�s	���Fll����ll����ll����l��������ll����l��������lll����)�assert_equalr&r')�self�r>�/usr/lib64/python3.6/helpers.py�test_bigint&s zBigIntTestCase.test_bigintN)�__name__�
__module__�__qualname__r@r>r>r>r?r9$sr9cCsdS)Nr>r>r>r>r?�test_bin_to_hex0srDc@s�eZdZejdd��Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�TestLocationWithoutEnvcCs2t|�}|jd|�|jtjj�s.|tjj7}|S)N�
BORG_KEYS_DIR)�str�setenv�endswith�os�path�sep)r=�tmpdir�monkeypatchr>r>r?�keys_dir6s
zTestLocationWithoutEnv.keys_dircCs|jddd�dS)N�	BORG_REPOF)�raising)�delenv)r=rNrOr>r>r?�test_ssh>s%zTestLocationWithoutEnv.test_sshcCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�	test_filegsz TestLocationWithoutEnv.test_filecCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_scposzTestLocationWithoutEnv.test_scpcCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_smb�szTestLocationWithoutEnv.test_smbcCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_folder�sz"TestLocationWithoutEnv.test_foldercCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_long_path�sz%TestLocationWithoutEnv.test_long_pathcCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_abspath�sz#TestLocationWithoutEnv.test_abspathcCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_relpath�sz#TestLocationWithoutEnv.test_relpathcCs|jddd�dS)NrPF)rQ)rR)r=rNrOr>r>r?�test_with_colons�sz'TestLocationWithoutEnv.test_with_colonscCsdS)Nr>)r=r>r>r?�test_user_parsing�sz(TestLocationWithoutEnv.test_user_parsingcCsdS)Nr>)r=r>r>r?�test_with_timestamp�sz*TestLocationWithoutEnv.test_with_timestampcCsj|jddd�tjt��td�WdQRXtjt��td�WdQRXtjt��t�WdQRXdS)NrPF)rQz	::archivez::)rR�pytest�raises�
ValueErrorr)r=rNr>r>r?�test_underspecified�sz*TestLocationWithoutEnv.test_underspecifiedc	Cs0|jddd�tjt��td�WdQRXdS)NrPF)rQz8/some/path/to/repo::archive_name_with/slashes/is_invalid)rRr^r_r`r)r=rNr>r>r?�test_no_slashes�sz&TestLocationWithoutEnv.test_no_slashescCs0|jddd�dddddd	g}x|D]}q$WdS)
NrPF)rQzsome/path::archivezfile://some/path::archivezhost:some/path::archivezhost:~user/some/path::archivezssh://host/some/path::archivez'ssh://user@host:1234/some/path::archive)rR)r=rNZ	locations�locationr>r>r?�test_canonical_path�s
z*TestLocationWithoutEnv.test_canonical_pathcCs2|jddd�tj�}td�}td�td�}dS)NrPF)rQz/some/path::archive{now:%s}g�������?)rRrJ�getpidrr)r=rNZtest_pidZlocation_time1Zlocation_time2r>r>r?�test_format_path�sz'TestLocationWithoutEnv.test_format_pathc	Cs"tjt��td�WdQRXdS)Nzssh://user@host:/path)r^r_r`r)r=r>r>r?�test_bad_syntax�sz&TestLocationWithoutEnv.test_bad_syntaxcCs ddlm}td�}|j�}dS)Nr)�hostnamez.ssh://user@host:1234/repos/{hostname}::archive)�
borg.platformrhrZomit_archive)r=rh�locZloc_without_archiver>r>r?�test_omit_archive�sz(TestLocationWithoutEnv.test_omit_archiveN)rArBrCr^ZfixturerOrSrTrUrVrWrXrYrZr[r\r]rarbrdrfrgrkr>r>r>r?rE5s$)
		
rEc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestLocationWithEnvcCs|jdd�dS)NrPzssh://user@host:1234/some/path)rH)r=rNr>r>r?rS�szTestLocationWithEnv.test_sshcCsddlm}|jdd�dS)Nr)rhrPzssh://user@host:1234/{hostname})rirhrH)r=rNrhr>r>r?�test_ssh_placeholdersz(TestLocationWithEnv.test_ssh_placeholdercCs|jdd�dS)NrPzfile:///some/path)rH)r=rNr>r>r?rTszTestLocationWithEnv.test_filecCs|jdd�dS)NrPzuser@host:/some/path)rH)r=rNr>r>r?rUszTestLocationWithEnv.test_scpcCs|jdd�dS)NrPrK)rH)r=rNr>r>r?rW!szTestLocationWithEnv.test_foldercCs|jdd�dS)NrPz/some/absolute/path)rH)r=rNr>r>r?rY*sz TestLocationWithEnv.test_abspathcCs|jdd�dS)NrPzsome/relative/path)rH)r=rNr>r>r?rZ3sz TestLocationWithEnv.test_relpathcCs|jdd�dS)NrPz/abs/path:w:cols)rH)r=rNr>r>r?r[<sz$TestLocationWithEnv.test_with_colonsc	Cs.|jdd�tjt��td�WdQRXdS)NrPz/some/absolute/pathz&::archive_name_with/slashes/is_invalid)rHr^r_r`r)r=rNr>r>r?rbEsz#TestLocationWithEnv.test_no_slashesN)rArBrCrSrmrTrUrWrYrZr[rbr>r>r>r?rl�s	
						rlc@seZdZdd�ZdS)�FormatTimedeltaTestCasecCs@tddddddd�}tddddddd	�}|jt||�d
�dS)Ni�r6�
��r��i��z2 hours 1.10 seconds)rr<r)r=Zt0Zt1r>r>r?�testMs

zFormatTimedeltaTestCase.testN)rArBrCrtr>r>r>r?rnKsrnc	Cs"tjt��td�WdQRXdS)Nz
19,24,21,4095)r^r_r`r+r>r>r>r?�test_chunkerparamsVsruc@seZdZdd�ZdS)�MakePathSafeTestCasecCs�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d	�|jtd�d	�dS)
Nz/foo/barzfoo/barz/f/barzf/barzfo/barz
../foo/barz
../../foo/bar�/�.)r<r)r=r>r>r?rt_szMakePathSafeTestCase.testN)rArBrCrtr>r>r>r?rv]srvc@seZdZdd�Zdd�ZdS)�MockArchivecCs
||_dS)N)�ts)r=rzr>r>r?�__init__lszMockArchive.__init__cCs
t|j�S)N)�reprrz)r=r>r>r?�__repr__oszMockArchive.__repr__N)rArBrCr{r}r>r>r>r?ryjsryc@seZdZdd�ZdS)�PruneSplitTestCasecs�dd��dd����fdd�}dddddddg}�fd
d�|D�}dd�|D�}||d
gdddg�||dgddddg�||d
|dgdddg�||d
|dgdddg�||d
|dgdddg�||dgg�dS)NcSs&ttd||fd��}tj|tjd�S)z1Convert noon on the month and day in 2013 to UTC.z2013-%02d-%02d 12:00z%Y-%m-%d %H:%M)Ztz)rrrZ
fromtimestampr�utc)�month�day�secondsr>r>r?�local_to_UTCwsz-PruneSplitTestCase.test.<locals>.local_to_UTCcs�fdd�|D�S)Ncsh|]}�|�qSr>r>)�.0�i)�lstr>r?�	<setcomp>}sz:PruneSplitTestCase.test.<locals>.subset.<locals>.<setcomp>r>)r��indicesr>)r�r?�subset|sz'PruneSplitTestCase.test.<locals>.subsetcs:x4|t|�fD]$}�jtt|d||���||��qWdS)Nz%Y-%m)�reversedr<�setr)�
test_archives�n�skipr��ta)r=r�r>r?�dotestsz'PruneSplitTestCase.test.<locals>.dotestr6r	�rq��csg|]\}}�||��qSr>r>)r�r�r�)r�r>r?�
<listcomp>�sz+PruneSplitTestCase.test.<locals>.<listcomp>cSsg|]}t|��qSr>)ry)r��dater>r>r?r��s�rrs)r6r6)r	r6)r	r�)rqr6)rqr	)rqr�)r�r6���r>)r=r�Z
test_pairs�
test_datesr�r>)r�r=r�r?rtuszPruneSplitTestCase.testN)rArBrCrtr>r>r>r?r~ssr~c@s$eZdZdd�Zdd�Zdd�ZdS)�IntervalTestCasecCsT|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd	�d
�dS)N�1Hr6Z1d��1w��1mi��1yi8")r<r)r=r>r>r?�
test_interval�s
zIntervalTestCase.test_intervalcCs�tjt��}td�WdQRX|j|jjd�tjt��}td�WdQRX|j|jjd�tjt��}td�WdQRX|j|jjd	�dS)
N�H�AUnexpected interval number "": expected an integer greater than 0z-1d�CUnexpected interval number "-1": expected an integer greater than 0Zfood�DUnexpected interval number "foo": expected an integer greater than 0)r�)r�)r�)r^r_rrr<�value�args)r=�excr>r>r?�test_interval_time_unit�sz(IntervalTestCase.test_interval_time_unitc
Cs2tjt��}td�WdQRX|j|jjd�dS)N�5�LUnexpected interval time unit "5": expected one of ['H', 'd', 'w', 'm', 'y'])r�)r^r_rrr<r�r�)r=r�r>r>r?�test_interval_number�s
z%IntervalTestCase.test_interval_numberN)rArBrCr�r�r�r>r>r>r?r��sr�c@seZdZdd�ZdS)�PruneWithinTestCasec	s>dd����fdd�}ddd d!d#d%g}tjtj���fdd�|D�}d
d�|D�}||ddg�||dddg�||ddddg�||dddddg�||ddddddg�||ddddddg�||dddddddg�||dddddddg�||dddddddg�||dddddddg�||dddddddg�dS)&Ncs�fdd�|D�S)Ncsh|]}�|�qSr>r>)r�r�)r�r>r?r��szHPruneWithinTestCase.test_prune_within.<locals>.subset.<locals>.<setcomp>r>)r�r�r>)r�r?r��sz5PruneWithinTestCase.test_prune_within.<locals>.subsetcs:x4|t|�fD]$}�jtt|t|����||��qWdS)N)r�r<r�rr)r�Zwithinr�r�)r=r�r>r?r��sz5PruneWithinTestCase.test_prune_within.<locals>.dotest�<�Z�����1csg|]}�t|d��qS))r�)r)r��s)�nowr>r?r��sz9PruneWithinTestCase.test_prune_within.<locals>.<listcomp>cSsg|]}t|��qSr>)ry)r�r�r>r>r?r��sr�rZ2Hr6Z3Hr	Z24HrqZ26HrsZ2dZ50Hr�Z3dr�r�r�ii(#i81i�i�_i|i�)rr�rr)r=r�Ztest_offsetsr�r�r>)r�r=r�r?�test_prune_within�s"z%PruneWithinTestCase.test_prune_withinN)rArBrCr�r>r>r>r?r��sr�c@seZdZdd�ZdS)�StableDictTestCasecCsLtddddd�}|jt|j��ddd
dg�|jtjtj|��j�d
�dS)Nr6r	rqrs)�foo�bar�boo�bazr�r�r�r�Z fc78df42cd60691b3ac3dd2a2b39903f)r�r	)r�rs)r�rq)r�r6)	r%r<�list�items�hashlibZmd5rZpackbZ	hexdigest)r=�dr>r>r?rt�szStableDictTestCase.testN)rArBrCrtr>r>r>r?r��sr�c@seZdZdd�ZdS)�TestParseTimestampcCsL|jtd�tdddddddtj��|jtd	�tdddddddtj��dS)
Nz2015-04-19T20:25:00.226410i�rs�rpr�rijtz2015-04-19T20:25:00)r<r)rrr)r=r>r>r?rt�s$zTestParseTimestamp.testN)rArBrCrtr>r>r>r?r��sr�cCsR|jddd�|jddd�|jddd�|jdd�|jdd�|jdd�d	S)
z+test that get_base_dir respects environmentZ
BORG_BASE_DIRF)rQ�HOMEZUSER�rootz
/var/tmp/homez
/var/tmp/baseN)rRrH)rNr>r>r?�test_get_base_dir�sr�cCs8|jddd�|jddd�|jdd�|jdd�dS)z-test that get_config_dir respects environmentZBORG_CONFIG_DIRF)rQ�XDG_CONFIG_HOMEz/var/tmp/.configz/var/tmpN)rRrH)rNr>r>r?�test_get_config_dir�s
r�cCs8|jddd�|jddd�|jdd�|jdd�dS)z,test that get_cache_dir respects environmentZBORG_CACHE_DIRF)rQZXDG_CACHE_HOMEz/var/tmp/.cachez/var/tmpN)rRrH)rNr>r>r?�test_get_cache_dir�s
r�cCs8|jddd�|jddd�|jdd�|jdd�dS)z+test that get_keys_dir respects environmentrFF)rQr�z/var/tmp/.configz/var/tmpN)rRrH)rNr>r>r?�test_get_keys_dirs
r�cCs8|jddd�|jddd�|jdd�|jdd�dS)z/test that get_security_dir respects environmentZBORG_SECURITY_DIRF)rQr�z/var/tmp/.configz/var/tmpN)rRrH)rNr>r>r?�test_get_security_dir
s
r�c*Csrddddddddd	d
dd
dd
ddddddddddd(dd)dd*dd+dd,d d-d"d.d$d/d%d0d&i}x|j�D]\}}qbWd'S)1z!test the size formatting routinesrz0 Br6z1 B�z142 Bi�z999 Bi�z1.00 kBi�i�z1.23 kBi�z1.24 kBi�z1.01 kBi�;z	999.99 MBi�;ix��;z1.00 GBror�z1.00 MB�	rrz1.00 TB�z1.00 PB�z1.00 EB�z1.00 ZBr�z1.00 YBz-1 Bz-1.01 kBNi@Biʚ;lJ)�l�I�5l�N�Zol@=7M.clB�3v^!<r�i���)r�)�si_size_map�size�fmtr>r>r?�test_file_sizes.r�cCsdS)Nr>r>r>r>r?�test_file_size_precision6sr�c
Cs2ddddddd	dd
di}x|j�D]\}}q"WdS)Nrz0 Br6z+1 Bi�z+1.23 kBz-1 Bz-1.23 kBr�i.���)r�)r�r�r�r>r>r?�test_file_size_sign<sr�zstring,value�1�20rp�5K��1.75M���1e+9�e��A�-1Tg��mBcCsdS)Nr>)�stringr�r>r>r?�test_parse_file_sizeHs	r�r���5 Äpfel�4E�2229 bit�1Bc	Cs"tjt��t|�WdQRXdS)N)r^r_r`r)r�r>r>r?�test_parse_file_size_invalidTsr�cCs tj}ztjt_Wd|t_XdS)N)rZPackerr )Zsaved_packerr>r>r?�test_is_slow_msgpack\sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
TestBuffercCstt�}tt�}dS)N)r�	bytearray�bytes)r=�bufferr>r>r?�	test_typehszTestBuffer.test_typecCs,ttdd�}|j�}ttdd�}|j�}dS)Nr)r�i�)rr��get)r=r��br>r>r?�test_lenns
zTestBuffer.test_lencCsRttdd�}|j�}|jd�|j�}|jd�|j�}|jddd�|j�}dS)N�d)r���T)Zinit)rr�r��resize)r=r��b1�b2�b3Zb4r>r>r?�test_resizevs

zTestBuffer.test_resizec	Cs>ttddd�}|jd�tjtj��|jd�WdQRXdS)Nr�r�)r��limit��)rr�r�r^r_�MemoryLimitExceeded)r=r�r>r>r?�
test_limit�s

zTestBuffer.test_limitc	CsRttddd�}|jd�}|jd�}|jd�}tjtj��|jd�WdQRXdS)Nr�r�)r�r��2r�)rr�r�r^r_r�)r=r�r�r�r�r>r>r?�test_get�s


zTestBuffer.test_getN)rArBrCr�r�r�r�r�r>r>r>r?r�gs
r�cCs@tt�}t|�}x|D]}qWtt�}t|�}x|D]}q4WdS)N)r�r"r8r#)�inputs�inputr�r>r>r?�test_yes_input�s

r�cCs8tt�}t|�}x|D]}qWt|�}x|D]}q,WdS)N)r�r$r8)r�r�r�r>r>r?�test_yes_input_defaults�s

r�cCstdddg�}dS)NZYESZSUREZNOPE)r8)r�r>r>r?�test_yes_input_custom�sr�cCs8xtD]}|jd|�qWxtD]}|jd|�q WdS)N�
OVERRIDE_THIS)r"rHr#)rNr�r>r>r?�test_yes_env�s

rcCsxtD]}|jd|�qWdS)Nr)r$rH)rNr�r>r>r?�test_yes_env_default�s
rc
CsHtdddg�}tdddg�}tg�}tjt��tdd�WdQRXdS)N�invalidr�� )�default)r8r^r_r`r!)r�r>r>r?�test_yes_defaults�s
rcCs(tddtdg�}tddtdg�}dS)Nr�r�r)r8r"r#)r�r>r>r?�test_yes_retry�srcCs(tddtdg�}tddtdg�}dS)Nr�r�r)r8r"r#)r�r>r>r?�test_yes_no_retry�srcCs*tdddg�}|j�\}}|j�\}}dS)Nr�yr�)r8�
readouterr)�capfdr��out�errr>r>r?�test_yes_output�srcCs d}|j|d�|j�\}}dS)NZOVERRIDE_SOMETHINGr!)rHr
)rrNZenv_varrr
r>r>r?�test_yes_env_output�srcCs�|jdd�|jdd�tddddd	�}|jjd
�|jd�|j�\}}|jd�|jd�|j�\}}|jd�|j�\}}|j�|j�\}}dS)
N�COLUMNS�4�LINESr�i�r�rz%3.0f%%)�step�start�msg�INFOi�i�)rHr,�logger�setLevel�showr
�finish)rrN�pirr
r>r>r?�!test_progress_percentage_samelines



rcCst|jdd�|jdd�tddddd	�}|jjd
�|j�|j�\}}|j�|j�\}}|j�|j�\}}dS)Nrrrr�r�r	rz%3.0f%%)rrrr)rHr,rrrr
)rrNrrr
r>r>r?�test_progress_percentage_stepsrcCs`tddddd�}|jjd�|jd�|j�\}}|jd�|j�\}}|j�|j�\}}dS)Ni�r�rz%3.0f%%)rrrZWARN)r,rrrr
r)rrrr
r>r>r?�test_progress_percentage_quiet(s

rcCsNtdtjd�}|j�|j�\}}|j�|j�\}}|j�|j�\}}dS)Nr6)r�file)r-�sys�stderrrr
r)rrrr
r>r>r?�test_progress_endless6sr"cCsbtdtjd�}|j�|j�\}}|j�|j�\}}|j�|j�\}}|j�|j�\}}dS)Nr	)rr)r-r r!rr
)rrrr
r>r>r?�test_progress_endless_stepCsr#cCsdS)Nr>r>r>r>r?�test_partial_formatSsr$cCs ttddg��}ttg��}dS)Nsabcsdef)r*�iter)Zcfwr>r>r?�test_chunk_file_wrapper[sr&cCs^tdd�}tjt��t|�WdQRXtjt��t|�WdQRXtdd�}tdd�}dS)NZabcdefgrqZabr�)r/r^r_�
StopIteration�next)�itr>r>r?�test_chunkitfs


r*cCsdjdd�}dS)Nz$#comment
data1 #data1
data2

 data3
T)�keepends)�
splitlines)Zconfr>r>r?�test_clean_lineswsr-cCstdd�}dS)Nzbar baz)r�)�dict)�datar>r>r?�test_format_line�s
r0cCsbt�}tjt��WdQRXtjt��WdQRXtjt��WdQRXtjt��WdQRXdS)N)r.r^r_r)r/r>r>r?�test_format_line_erroneous�s


r1cCstj�}dS)N)rr�)r�r>r>r?�test_replace_placeholders�sr2cCsdS)Nr>r>r>r>r?�test_override_placeholders�sr3cCstjd�dkS)Nu선r	)r
Zswidthr>r>r>r?�working_swidth�sr4z"swidth() is not supported / active)�reasoncCsd}dS)Nu-나윤선나윤선나윤선나윤선나윤선r>)r�r>r>r?�test_swidth_slice�sr6cCsd}dS)Nu.나윤a선나윤선나윤선나윤선나윤선r>)r�r>r>r?�"test_swidth_slice_mixed_characters�sr7c	CsZtr.dd}tjt��tj|�WdQRXn(dd}tjt��tj|�WdQRXdS)Nr	r�)r2r^r_�
OverflowErrorrZutcfromtimestamp)Zbeyond_y10kr>r>r?�test_safe_timestamps�s	r9c@sheZdZejjejd�dd�dd��Zejjejd�dd�dd	��Z	ejj
d
d�dd��Zdd�ZdS)�TestPopenWithErrorHandlingrtz"test" binary is needed)r5cCstd�}dS)Nztest 1)r3)r=�procr>r>r?�test_simple�sz&TestPopenWithErrorHandling.test_simplezborg-foobar-test-notexistz4"borg-foobar-test-notexist" binary exists (somehow?)cCstd�}dS)Nzborg-foobar-test-notexist 1234)r3)r=r;r>r>r?�test_not_found�sz)TestPopenWithErrorHandling.test_not_found�cmd�mismatched "quote�foo --bar="bazr�cCst|�}dS)N)r3)r=r>r;r>r>r?rg�sz*TestPopenWithErrorHandling.test_bad_syntaxcCs&tjt��tddd�WdQRXdS)Nr�T)�shell)r^r_�AssertionErrorr3)r=r>r>r?�
test_shell�sz%TestPopenWithErrorHandling.test_shellN)r?r@r�)
rArBrCr^�mark�skipif�shutilZwhichr<r=�parametrizergrCr>r>r>r?r:�s r:cCsdS)Nr>r>r>r>r?�test_dash_open�srHcCs8d}|d}|j|�|d}|j|�tt|��dS)Ns
Hello, world
�victim�hardlink)�write_binary�mklinktor5rG)rM�contentsrI�	hard_linkr>r>r?�test_safe_unlink_is_safe�s

rOc
Csdd}|d}|j|�|d}|j|�dd�}|jtd|�tjt��tt|��WdQRXdS)Ns
Hello, world
rIrJcSsttjd��dS)Nz Pretend that we ran out of space)�OSError�errnoZENOSPC)�_r>r>r?�	os_unlinksz2test_safe_unlink_is_safe_ENOSPC.<locals>.os_unlink�unlink)	rKrL�setattrrJr^r_rPr5rG)rMrNrMrIrNrSr>r>r?�test_safe_unlink_is_safe_ENOSPCs

rV�r�r6�r�rp�r�r��r�r��r�r����m©r�r\)rWrXrYrZr[r])r�r�r�r�r�){rQr��iorJrFr �argparserrrrZtimerrrr^r�r
Zhelpersrrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r7r8r9rDrErlrnrurvryr~r�r�r�r�r�r�r�r�r�r�r�r�rDrGr�r�r�r�r�r�r�rrrrrrrrrrr"r#r$r&r*r-r0r1r2r3r4rEr6r7r9r:rHrOrVr>r>r>r?�<module>s�$GP
	!7