a ze#@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZddlmZmZzddlZddlZWneydZZYn0GdddeZGdddee jZGd d d ee jZGd d d eZGd ddee jZGdddee jZGdddee jZejeZ ddZ!ddZ"e #ej$dkdZ%e #ej$dkdZ&e&GdddeZ'e%GdddeZ(GdddeZ)Gdd d e)e jZ*e&Gd!d"d"e)e jZ+e%Gd#d$d$e)e jZ,Gd%d&d&e jZ-e.d'kre /dS)(N)mock)support)TESTFNFakePathc@seZdZddZddZdS)_BaseFlavourTestcsd|jj}|jj|jj|fdd|D}|||r`|fdd|D}|||dS)Ncsg|]}|dqS/replace.0x)sepE/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_pathlib.py z7_BaseFlavourTest._check_parse_parts..csg|]}|dqSrr r )altseprrr r)flavour parse_partsrr assertEqual)selfargexpectedfactualr)rrr_check_parse_partss z#_BaseFlavourTest._check_parse_partscCs|j}|jj}|gddgf|dgdddgf|dgdddgf|ddgddddgf|dgddddgf|dgddddgf|gdddgdf|gd ddgdf|gd ddgdf|d gddgf|gd dddgf|gd ddddgf|gddddgf|dgd||ddgf|ddgd||ddgf|ddgd||ddgf|gdd||ddgf|gdd||dgfdS)Naa/ba/ba/b/)rzb/cd)rr cr#)rzb//cr#)rzb/c/r#.)r%r%r )rr%r )rr%r%/a/b/a/a/r/br$r$)rr*/c)rrr)rcheckrrrrtest_parse_parts_common#s(z(_BaseFlavourTest.test_parse_parts_commonN)__name__ __module__ __qualname__rr-rrrrrs rc@s"eZdZejZddZddZdS)PosixFlavourTestcCs|j}|ddgddgdf|ddgddgdf|d dgddgdf|d gddd gf|d gddd gf|d gddd gfdS) N//ar r//)r3rr ///ar)rrr z////ac:ac:\a\arrr,rrrtest_parse_partsCsz!PosixFlavourTest.test_parse_partscCs|jj}||dd||dd||dd||dd||d d ||d d ||d d||dd||dd ||dd ||dd||dd||dddS)Nrrrrrrrrr!)rrr!r")rrr"r')rrrr&)rrr!/a/b/)rrr"r2)rr3rr4///a/bc:/a/b)rrr?\/a/b)rrr@\a\b)rrrAr splitrootrrrrrrtest_splitrootOszPosixFlavourTest.test_splitrootN)r.r/r0pathlib_posix_flavourrr:rErrrrr1@s r1c@s"eZdZejZddZddZdS) NTFlavourTestcCs|j}|dgdddgf|dgdddgf|dgdddgf|dgddddgf|d gddddgf|d gddddgf|d gd dd gf|dgd dd gf|dgd dd dgf|gdddgdf|gdddgdf|gdddddgf|gdddgdf|gdddddgf|dgdddgf|d gddddgf|d d!gdddd"gf|d#gd$dd%gf|d&gd$dd%dgf|gd'ddgd(f|gd)ddgdf|gd*d+dgd,fdS)-Nc:rc:/\c:\rr5rc:/ar'//a/b\\a\b\\a\b\//a/b///a/b/cr$)rzZ:br$Z:)rSr r$)rzZ:/br$)Z:\r r$)rz//b/cr#z\\b\cz\\b\c\r#)rz Z://b//c/d/)rTr r$r#)rz//b/c//r#z//?/c:/z\\?\c:z\\?\c:\z//?/c:/ar*r z //?/UNC/b/cz \\?\UNC\b\cz \\?\UNC\b\c\z //?/UNC/b/c/dr))rKr r$)zZ:/ar*r$)z//?/Z:/ar*r$z\\?\Z:)z\\?\Z:\r r$r8r9rrrr:gs.zNTFlavourTest.test_parse_partscCs |jj}||dd||dd||dd||dd||d d ||d d ||d d||dd||dd||dd||dd||dd||dd||dd||dd ||dddS)Nrr;rr<a\b)rrrVr7)rrKrrA)rrKrVzc:a\b)rIrrVzc:\a\b)rIrKrVz\\az\\\a/b)rrKr!zc:\\a)rIrKrzc:\\\a/b)rIrKr!rO)rOrKrrP \\a\b\c\d)rOrKc\dz\\\a\brBrDrrrrEs"zNTFlavourTest.test_splitrootN)r.r/r0rF_windows_flavourrr:rErrrrrHds"rHc@s&eZdZgdgddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"dBdCZ#dDdEZ$dFS)G_BasePurePathTest) rr )rr )rb/)rr\)r")za//b)za//b//)rrr )rrr )rr r))r/b/cr#)rz///b//crU)r'r]r#)rr rc/d)rrzb/c/d)r/b/c/d)r!r_cCs*|d}|j|_|jj|_|jj|_dSNr)cls_flavourrrrrprrrsetUps  z_BasePurePathTest.setUpcCs|j}|d}||||ddd|ddd|d|d|td|||d|d|||dd|d|||d|d|d|||d|d|d|tddS)Nrr r$r'a/b/c/a/b/cr!)raassertIsInstancerrrPrdrrrtest_constructor_commons    z)_BasePurePathTest.test_constructor_commoncs\Gdddt|j}|fdd|D}|||||jD]}|t|tqBdS)Nc@s eZdZdS)z:_BasePurePathTest._check_str_subclass..StrSubclassN)r.r/r0rrrr StrSubclasssrlc3s|]}|VqdSNrr rlrr rz8_BasePurePathTest._check_str_subclass..)strrarpartsassertIstype)rargsrjrdpartrrnr_check_str_subclasss  z%_BasePurePathTest._check_str_subclasscCs6|d|d|d|d|ddS)Nrr%rza/b.txtz/a/b.txtrvrrrrtest_str_subclass_commons     z*_BasePurePathTest.test_str_subclass_commoncCs|j}|d}|d}|||d|t|t||dd}|||d||d}|||d|d}|||ddS)Nr!r$rfr#a/b/c/dr+)rajoinpathrrrrsrrjrdpprrrtest_join_commons   z"_BasePurePathTest.test_join_commoncCs|j}|d}|d}|||d|t|t||d}|||d|dd}|||dd|d}|||d||d}|||d|d}|||ddS) Nr!r$rfr^rzr#zc/a/b/dr+)rarrrrsr|rrrtest_div_commons   z!_BasePurePathTest.test_div_commoncCs(|j|}|t||d|jdSNr)rarrpr r)rrrtrdrrr _check_strs z_BasePurePathTest._check_strcCs(dD]}|||fq|dddS)Nrr!rfrr&rgr%)r)r)rpathstrrrrtest_str_commonsz!_BasePurePathTest.test_str_commoncCs(|j}dD]}||||q dS)Nr)raras_posix)rrjrrrrtest_as_posix_common sz&_BasePurePathTest.test_as_posix_commoncCs2t|j}|j}|t|dd|ddS)Nr!ab)osfsencoderrarbytes)rrrjrrrtest_as_bytes_commons z&_BasePurePathTest.test_as_bytes_commoncCst|j}|t|dWdn1s20Y|t|Wdn1sf0YdSr`)ra assertRaises ValueErroras_urirrjrrrtest_as_uri_commons  * z$_BasePurePathTest.test_as_uri_commoncCsdD]}||}|jj}t|}|||d|||d||t|dd}|t || t |t j }| |j|j||||t||qdS)Nr())ra __class__r.repr assertTrue startswithendswithlenrevalrrF__dict__rr)rrrdZclsnamerinnerqrrrtest_repr_commons   z"_BasePurePathTest.test_repr_commoncCs|j}||d|d||d|dd||d|d||d|d||d|||d|d|||d||d||i||tdS)Nr!rr r&rr)rarassertNotEqualintrrrrtest_eq_common-sz _BasePurePathTest.test_eq_commoncCsN|j}|t|djd|t|djd||dd||dd||dd||dd||dd||d d||d d||dd ||dd ||dd ||d d ||d d ||d d ||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd||dddS)Nrrr%b.pya/b.py/a/b.pyza.pyzb/pyz/a.pyzb.py/cz*.pyzb.pyczb./pyzab/c.pyza*/*.pyz /d/ab/c.pyz /dab/c.pyz ab/c.py/d/b.py/*.pyz/a/*.pyz/ab.pyz /a/b/c.pyz/**/*.pyz /a/**/*.py)rarrmatchr assertFalserrrrtest_match_common:s<z#_BasePurePathTest.test_match_commoncsfdd}j}|d}|d}|d}|d}|||||||||||||||j}|d}|d}|d }|d }|||||||||||||||t|ikWdn1s0YdS) Ncs||||dSrm) assertLessZ assertGreaterr[rxrrrbs z:_BasePurePathTest.test_ordering_common..assertLessrr!abcr r'r&z/abcr*)rar TypeError)rrrjrr r$r#rrxrtest_ordering_common`s.            z&_BasePurePathTest.test_ordering_commoncCsX|j}|j}|d}|j}||d|||j|d}|j}|||ddfdS)Nr!r[r&rr )rrarqrrr)rrrjrdrqrrrtest_parts_common|s z#_BasePurePathTest.test_parts_commoncCs4|j}|d}||d|t|ddS)Nr!)r!)rar __fspath__rfspathrirrrtest_fspath_commonsz$_BasePurePathTest.test_fspath_commonc sjD]\}}|dj}|jd}||krX|fdd|D}||f|}|D]V}j|}||d|t|t|t ||| |qfq dS)Nrcs"g|]}tfdd|DqS)c3s|]}|djVqdS)rN)r r)r rurxrrrorzA_BasePurePathTest.test_equivalences...)tuple)r trxrrrsz7_BasePurePathTest.test_equivalences..zfailed with args {}) equivalencesitemsr rappendrarformathashrpr)rkZtuplesZcanonposixZpcanonrrdrrxrtest_equivalencess    z#_BasePurePathTest.test_equivalencescCs|j}|d}||j|d||jj|d||jjj|||jjjj||d}||j|d||jj|d||jjj|d||jjjj|ddS)Nrfr!rrgr&r'rrarparentrirrrtest_parent_commonsz$_BasePurePathTest.test_parent_commoncCs|j}|d}|j}|t|d||d|d||d|d||d|d|t||d|d|dg|t|d Wdn1s0Y|t|dWdn1s0Y|t||d<Wdn1s0Y|d }|j}|t|d||d|d ||d|d ||d|d |t||d |d |d g|t|dWdn1s0YdS)Nrfrr!rrr%rrgr&r'r)raparentsrrlistr IndexErrorrrrjrdZparrrrtest_parents_commons." & & (" z%_BasePurePathTest.test_parents_commoncCs@|j}||djd||djd||djddS)Nr!rr&rardriverrrrtest_drive_commonsz#_BasePurePathTest.test_drive_commoncCsX|j}|j}||djd||djd||dj|||dj|dSNrr!rr&)rarrrootrrjrrrrtest_root_commons z"_BasePurePathTest.test_root_commoncCsX|j}|j}||djd||djd||dj|||dj|dSr)rarranchorrrrrtest_anchor_commons z$_BasePurePathTest.test_anchor_commoncCs|j}||djd||djd||djd||djd||djd||djd||djd ||d jd dS) Nrr%rr!r r&/a/b/.rrrrarnamerrrrtest_name_commonsz"_BasePurePathTest.test_name_commoncCs<|j}||djd||djd||djd||djd||djd||djd||djd||djd ||d jd ||d jd||d jd||d jd||djd||djd||djd||djd||djddS)Nrr%..rr!r&rr.pyra/.hgrc/a/.hgrca/.hg.rc.rc /a/.hg.rc a/b.tar.gz.gz /a/b.tar.gza/Some name. Ending with a dot. /a/Some name. Ending with a dot.rarsuffixrrrrtest_suffix_commons$z$_BasePurePathTest.test_suffix_commoncCs:|j}||djg||djg||djg||djg||djg||djg||djdg||d jdg||d jg||d jg||d jd g||djd g||djddg||djddg||djg||djgdS)Nrr%rr!r&rrrrrrrrrr.tarrrrrrarsuffixesrrrrtest_suffixes_commons"z&_BasePurePathTest.test_suffixes_commoncCs|j}||djd||djd||djd||djd||djd||djd||djd ||d jd ||d jd ||djddS)Nrr%rrr!r rr.hgrcr.hgrb.tarrSome name. Ending with a dot.rarstemrrrrtest_stem_commons z"_BasePurePathTest.test_stem_commoncCs2|j}||dd|d||dd|d||dd|d||dd|d||dd|d||d d|d|t|d jd|t|d jd|t|d jd|t|djd |t|djd |t|djd|t|djddS)Nr!d.xmlza/d.xmlr&z/a/d.xmlrr a/Dot ending./a/Dot ending.rr%rr+c/r^rar with_namerrrrrrtest_with_name_common"sz'_BasePurePathTest.test_with_name_commoncCsL|j}||dd|d||dd|d||dd|d||dd|d ||d d|d ||d d|d||d d|d|t|djd|t|djd|t|djd|t|djd|t|djd|t|djd|t|djddS)Nr!r#za/dr&z/a/drza/d.pyrz/a/d.pyrz/a/d.gzrrrr%rr+rr^rar with_stemrrrrrrtest_with_stem_common2sz'_BasePurePathTest.test_with_stem_commoncCs|j}||dd|d||dd|d||dd|d||dd|d||dd|d||dd|d|t|djd|t|d jd|t|d jd|t|djd |t|djd |t|djd |t|djd |t|djd |t|djd|t|djd|t|djd|t|dj|jjdfdS)Nr!rza/b.gzr&z/a/b.gzrrrr%rgz/.gzr^z.c/.dz./.dz.d/.r#)rar with_suffixrrrrrrrrtest_with_suffix_commonCs* z)_BasePurePathTest.test_with_suffix_commoncCsR|j}|d}|t|j|t|jd||||d||d|d|||d|d||d|d||d|d|||d|||d|||dd||t|j|d|t|j|d|t|j|d |t|j|d |d }|||d |d||d |d|||d |d||d |d||d |d|||d |||d ||t|j|d|t|j|d|t|j|d|t|j||t|jd|t|j|ddS)Nr!rrrr rr$rfa/cr'r&rr(r+rg/a/c)rarr relative_torrrirrrtest_relative_to_common\s<z)_BasePurePathTest.test_relative_to_commoncCs|j}|d}|t|j|t|jd|||||d|||d||d|||d||d||dd|||d|||d|||d |||d |d }|||d ||d |||d ||d ||d |||d ||d |||d|||d|||d|||||d|||ddS)Nr!rrrrr r$rfrr'r&rr(r+rgr)rarris_relative_torrrirrrtest_is_relative_to_commons:z,_BasePurePathTest.test_is_relative_to_commoncCs|j}|d}tdtjdD]^}t||}t|}||j|j||||t |t ||t |t |qdS)Nr&rr) rarangepickleHIGHEST_PROTOCOLdumpsloadsrrrrrrp)rrjrdprotodumpedr}rrrtest_pickling_commons   z&_BasePurePathTest.test_pickling_commonN)%r.r/r0rrerkrvryr~rrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrZsH   & #"rZc@sZeZdZejZddZddZddZddZ d d Z d d Z d dZ ddZ ddZdS)PurePosixPathTestcCs@|j}||djd||djd||djddS)Nr&rr>rNr3rarrrrrr test_rootszPurePosixPathTest.test_rootcCsF|j}||d|d||d|d||d|ddS)Nr!A/br'r4r2)rarrrrrrtest_eqszPurePosixPathTest.test_eqcCsF|j}||dd||dd||dddS)Nrzfile:///z/a/b.cz file:///a/b.cz/a/b%#czfile:///a/b%25%23c)rarrrrrr test_as_uriszPurePosixPathTest.test_as_uricCsdddlm}|j}ztdWnty<|dYn0||dd|tddS)Nr)quote_from_byteséz1\xe9 cannot be encoded to the filesystem encodingu/a/béz file:///a/b) urllib.parserrarrUnicodeEncodeErrorskipTestrr)rrrjrrrtest_as_uri_non_asciis  z'PurePosixPathTest.test_as_uri_non_asciicCs|j}||dddS)NzA.pyza.PY)rarrrrrr test_matchszPurePosixPathTest.test_matchcCs|j}||||d||d||d||d||d||d||ddS)Nrr"rr'r=r2rNrar is_absoluterrrrrtest_is_absolutesz"PurePosixPathTest.test_is_absolutecCsZ|j}|d|d|d|d|d|d|d|ddS)NFrr/foo/barz/dev/con/PRN/NULrarr is_reservedrrrrtest_is_reserveds z"PurePosixPathTest.test_is_reservedcCsh|j}|d}|d}|||d|dd}|||d|dd}|||ddSNr2r rNr'z//cr+rar{rr|rrr test_joins zPurePosixPathTest.test_joincCsb|j}|d}|d}|||d|dd}|||d|dd}|||ddSr rarr|rrrtest_divs  zPurePosixPathTest.test_divN)r.r/r0rF PurePosixPathrarrrrrrrr"r$rrrrr s   r c@seZdZejZejZe gdgddgddgdddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Z d5d6Z!d7d8Z"d9S):PureWindowsPathTest))rIr)rIr)rrIr))rJr)rIrr)rIr')z/zrJr)z//x/yrJr)rN)rNr$)rQr$)r5rMrQrRcCs|d}|t|d|d}|t|d|d}|t|d|d}|t|d|d }|t|d dS) Nrfza\b\czc:/a/b/czc:\a\b\crNrPrRz\\a\b\c //a/b/c/drW)rarrprcrrrtest_str s     zPureWindowsPathTest.test_strcCs^|d|d|d|d|d|d|d|d|d dS) NrIr5z c:a\b.txtrLr6z c:\a\b.txtz \\some\sharez\\some\share\az\\some\share\a\b.txtrwrxrrrtest_str_subclasss        z%PureWindowsPathTest.test_str_subclasscCs|j}||d|d||d|ddd||d|d||d|d||d|d||d|d ||d |d ||d |d dS)Nc:a/brIrr zd:a/br?r&za/BrC:a/Bc:A/b//Some/SHARE/a/Bz//somE/share/A/b)rarrrrrrr szPureWindowsPathTest.test_eqcCs|j}|t|dWdn1s20Y|t|dWdn1sh0Y||dd||dd||dd||d d ||d d ||d d||dddS)Nr&r*rJz file:///c:/zc:/a/b.czfile:///c:/a/b.cz c:/a/b%#czfile:///c:/a/b%25%23cuc:/a/bézfile:///c:/a/b%C3%A9z //some/share/zfile://some/share/z//some/share/a/b.czfile://some/share/a/b.cu//some/share/a/b%#céz"file://some/share/a/b%25%23c%C3%A9)rarrrrrrrrr,s  * *zPureWindowsPathTest.test_as_uricCsr|j}||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd||d d||d d ||d d ||d d ||d d||dd||dddS)Nzc:/b.pyrzc:*.pyzc:/*.pyzd:/b.pyrzc:b.pyrz//some/share/a.pyz//some/share/*.pyz//other/share/a.pyz//some/share/a/b.pyzB.pyzb.PYz c:/a/B.Pyz C:/A/*.pYz//Some/Share/B.Pyz//somE/sharE/*.pY)rarrrrrrrr<s&z%PureWindowsPathTest.test_match_commoncsfdd}j}|d}|d}|||||k||k|d}|d}|||||k||kdS)Ncs||||dSrm)ZassertLessEqualassertGreaterEqualr[rxrrassertOrderedEqualVs zDPureWindowsPathTest.test_ordering_common..assertOrderedEqualr,r+z//some/Share/A/br-)rar)rr/rjrdrrrxrrTs   z(PureWindowsPathTest.test_ordering_commoncCsX|j}|d}|j}||d|d}|j}||d|d}|j}||ddS)Nr*)rIrr r?)rLrr r')rPr$r#)rarqr)rrjrdrqrrr test_partses  zPureWindowsPathTest.test_partscCs|j}|d}||j|d||jj|d||jjj|d||jjjj|d|d}||j|d||jj|d||jjj|d||jjjj|d|d }||j|d ||jj|d ||jjj|d dS) Nzz:a/b/czz:a/bz:az:zz:/a/b/czz:/a/bz:/az:/r'rRrNrrirrr test_parentqszPureWindowsPathTest.test_parentcCs|j}|d}|j}|t|d||d|d||d|d|t||d|dg|t|dWdn1s0Y|d}|j}|t|d||d|d||d|d |t||d|d g|t|dWdn1s&0Y|d }|j}|t|d||d|d ||d|d |t||d |d g|t|dWdn1s0YdS) Nzz:a/b/rrr1rr2zz:/a/b/r3r4r'rRrN)rarrrrrrrrrr test_parentss2 & ( z PureWindowsPathTest.test_parentscCs|j}||djd||djd||djd||djd||djd||djd||djddS) NrIr*rJc:/a/b/rNrOrQr'rrrrr test_driveszPureWindowsPathTest.test_drivecCs|j}||djd||djd||djd||djd||djd||djd||d jddS) NrIrr*rJrKr7rNrQr'r rrrrrszPureWindowsPathTest.test_rootcCs|j}||djd||djd||djd||djd||djd||djd||d jddS) NrIr*rJrLr7rNrPrQr')rarrrrrr test_anchorszPureWindowsPathTest.test_anchorcCs|j}||djd||djd||djd||djd||djd||d jd||d jd||d jddS) NrIrrJr*r r?c:a/b.pyr c:/a/b.py//My.py/Share.php//My.py/Share.php/a/brrrrr test_nameszPureWindowsPathTest.test_namecCs*|j}||djd||djd||djd||djd||djd||djd||d jd||d jd||d jd ||d jd ||djd||djd||djd||djd||djd||djddS)NrIrrJr*r?r:rr; c:a/.hgrc c:/a/.hgrc c:a/.hg.rcr c:/a/.hg.rc c:a/b.tar.gzr c:/a/b.tar.gz!c:a/Some name. Ending with a dot."c:/a/Some name. Ending with a dot.r<r=rrrrr test_suffixs"zPureWindowsPathTest.test_suffixcCs:|j}||djg||djg||djg||djg||djdg||djdg||djg||d jg||d jd g||d jd g||d jddg||djddg||djg||djg||djg||djgdS)NrIrJr*r?r:rr;r?r@rArrBrCrrrDr<r=rErFrrrrr test_suffixess"z!PureWindowsPathTest.test_suffixescCs|j}||djd||djd||djd||djd||djd||d jd||d jd ||d jd ||djd||djddS)NrIrzc:.zc:..rrJr*r r:r?rrArrCrrErrrrrr test_stems zPureWindowsPathTest.test_stemcCs|j}||dd|d||dd|d||dd|d||dd|d|t|djd|t|d jd|t|d jd|t|djd |t|djd |t|djd |t|djd dS)Nr*rz c:a/d.xmlr?z c:/a/d.xmlc:a/Dot ending.c:/a/Dot ending.rIrJ //My/Shared:d:ed:/errrrrtest_with_namesz"PureWindowsPathTest.test_with_namecCs|j}||dd|d||dd|d||dd|d||dd|d|t|djd|t|d jd|t|d jd|t|djd |t|djd |t|djd |t|djd dS)Nr*r#zc:a/dr?zc:/a/drJrKrIrJrLrMrNrOrrrrrtest_with_stem sz"PureWindowsPathTest.test_with_stemcCs|j}||dd|d||dd|d||dd|d||dd|d|t|djd|t|d jd|t|d jd|t|d jd|t|djd |t|djd |t|djd |t|djd|t|djd|t|djd|t|djd|t|djd|t|djd|t|djd|t|djddS)Nr*rzc:a/b.gzr?z c:/a/b.gzr:r;rr%rrLrrKrIrz\.gzzc:.gzr^rXz.c/dz.c\d)rarrrrrrrrtest_with_suffixs(z$PureWindowsPathTest.test_with_suffixcCs0|j}|d}|||d|d||d|d|||d|d||d|d||d|d|||d|||d||t|j||t|jd|t|j|d |t|j|d |t|j|d |t|j|d |t|j|d |t|j|d|t|j|d|d}|||d|d||d|d|t||dd|t|dd|||d|d||d|d|||d|d||d|d||d|d|||d|||d||t|j|d|t|j|d|t|j|d|t|j|d|t|j|d |t|j|d|t|j|d |t|j|d |t|j|d|d}|||d|d||d|d||d|d|||d |d||d |d||d!|d|||d"|||d"||t|j|d#|t|j|d$|t|j|d%|t|j|d&dS)'N C:Foo/BarrIzFoo/Barc:foOZBarc:foO/ c:foO/baRrrMrFoo/FooC:/Foo C:Foo/Bar/Baz C:Foo/Baz C:/Foo/Barz/Foo/Barz\Foo\BarrJc:/foOc:/foO/ c:/foO/baRC:/BazC:/Foo/Bar/Baz C:/Foo/BazC:Food:///C/Foo//Server/Share/Foo/Bar//sErver/sHare//sErver/sHare///sErver/sHare/Foo//sErver/sHare/Foo///sErver/sHare/Foo/Bar/Server/Share/Fooc:/Server/Share/Foo //z/Share/Foo//Server/z/Foo)rarrrrrprirrrtest_relative_to0shz$PureWindowsPathTest.test_relative_tocCsH|j}|d}|||d||d|||d||d||d|||d||d|||||d|||d|||d|||d |||d |||d |||d |||d |d}||d|||d|||d||d|||d||d|||d|||d|||d|||d|||d|||d|||d|||d |||d|d}|||d||d||d|||d||d||d|||d||d|||d|||d |||d!|||d"dS)#NrSrIrTrUrVrrMrrWrXrYrZr[r\rJr]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnro)rarrrrirrrtest_is_relative_tojs^z'PureWindowsPathTest.test_is_relative_tocCs(|j}||||d||d||d||d||d||d||d||d||d ||d ||d ||d ||d ||d||ddS)Nrr"rr'r=rIr5zc:a/b/rJrMr7rNrQrRr'rrrrrrs"z$PureWindowsPathTest.test_is_absolutecCs|j}|d}|d}|||d|d}|||d|d}|||d|d}|||d|d}|||d|d }|||d|d }|||ddS) NC:/a/bx/y C:/a/b/x/y/x/yC:/x/yD:x/yD:/x/y//host/share/x/yc:x/yc:/x/yr!r|rrrr"s        zPureWindowsPathTest.test_joincCs|j}|d}||d|d||dd|d||d|d||dd|d||d |d ||d d|d ||d |d ||d d|d ||d |d ||d |d||d|ddS)Nrrrsrtr yrurvz/xrwzD:rxryrzr{r#rirrrr$szPureWindowsPathTest.test_divcCs|j}|d|d|d|d|d|d|d|d|d|d|d|d|d|d |d|d |d|d |d|d |d|d |d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|ddS)NFrrrz//my/share/nul/con/auxTnulZauxZprnZconzconin$zconout$ZCOM1ZLPT9ucom¹ucom²ulpt³zNUL.txtzPRN z AUX .txtzCOM1:barz LPT9 :barzbar.com9zbar.lpt9zc:/baz/con/NULzc:/NUL/con/bazrrrrrrs2z$PureWindowsPathTest.test_is_reservedN)#r.r/r0rFPureWindowsPathrarZrcopyupdater(r)rrrrr0r5r6r8rr9r>rGrHrIrPrQrRrprqrr"r$rrrrrr&sD          :5r&c@s*eZdZejZddZddZddZdS) PurePathTestcCs0|d}|t|tjdkr$tjntjdSNrnt)rarrrsrrrFr~r%rcrrrtest_concrete_classs  z PurePathTest.test_concrete_classcCs$td}td}|||dSr`)rFr%r~rrrdrrrrtest_different_flavours_unequal s  z,PurePathTest.test_different_flavours_unequalcCstd}td}|t||kWdn1s<0Y|t||kWdn1sn0Y|t||kWdn1s0Y|t||kWdn1s0YdSr`)rFr%r~rrrrrr!test_different_flavours_unordereds   & & & z.PurePathTest.test_different_flavours_unorderedN) r.r/r0rFPurePathrarrrrrrrrsrcGstjjtg|RSrm)rpathjoinBASEr rrr!rrcGstjjtg|RSrm)rrrrrrrrr"rrz)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc@seZdZejZdS)PosixPathAsPureTestN)r.r/r0rF PosixPathrarrrrr)src@s"eZdZejZddZddZdS)WindowsPathAsPureTestcCs@|j}|t|dWdn1s20YdSNrJ)rarNotImplementedErrorownerrrrr test_owner1s z WindowsPathAsPureTest.test_ownercCs@|j}|t|dWdn1s20YdSr)rarrgrouprrrr test_group6s z WindowsPathAsPureTest.test_groupN)r.r/r0rF WindowsPathrarrrrrrr-src@seZdZdZddZejdkr(ddZnddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zejd&d'Zd(d)Zd*d+Zd,d-Zejd.d/Zd0d1Zd2d3Zejd4d5Z dd7d8Z!e!Z"Z#ejd9d:Z$ejd;d<Z%d=d>Z&d?d@Z'dAdBZ(ejdCdDZ)dEdFZ*e+,e-dGdHdIZ.e+,e/dJdKdLZ0dMdNZ1dOdPZ2dQdRZ3e+,e4edSdTdUdVZ5e+6e4edSdWdXdYZ7dZd[Z8d\d]Z9ejd^d_Z:d`daZ;dbdcZdhdiZ?djdkZ@dldmZAeBdndoZCdpdqZDdrdsZEdtduZFejdvdwZGdxdyZHdzd{ZIeJd|d}ZKd~dZLddZMe+,e4eddddZNddZOe+,e4ePddddZQddZRddZSddZTddZUddZVddZWejddZXejddZYejddZZdS) _BasePathTestz?Tests for the FS-accessing functionalities of the Path classes.cCsdd}||ttttdttdttdttddttdttdd }|d Wdn1s0Yttdd d }|d Wdn1s0Yttdd d }|dWdn1s0Yttdddd }|dWdn1sF0Yttddt rt dtdt dtd| dtd| tj ddtdd| tj ddtddt dtddS)NcSsttddttdS)NdirE)rchmodrrrmtreerrrrrcleanupSsz$_BasePathTest.setUp..cleanupdirAdirBdirCZdirDrfileAwbsthis is file A fileBsthis is file B ZfileCsthis is file C ZfileDsthis is file D rlinkA non-existing brokenLinklinkBrlinkClinkDbrokenLinkLoop) addCleanuprmkdirrropenwriterr can_symlinksymlinkdirlinkr)rrrrrrreRs0  ((** z_BasePathTest.setUprcCstj||dddS)NTtarget_is_directoryrrrsrcdestrrrrssz_BasePathTest.dirlinkcCst||dSrmrrrrrrvscCs*|tjt|t|d||fdS)Nz&%r and %r don't point to the same file)rrrsamefilerprZpath_aZpath_brrr assertSameys z_BasePathTest.assertSamecOsN|t}||i|Wdn1s.0Y||jjtjdSrm)rFileNotFoundErrorr exceptionerrnoENOENT)rfuncrtkwargscmrrrassertFileNotFound~s ,z _BasePathTest.assertFileNotFoundcCs |tj|tj|dSrm)rrrnormcaserrrrassertEqualNormCasesz!_BasePathTest.assertEqualNormCasecCsT|t}||||t|t||t|t||| dSrm) rargetcwdrrrprrrsrrrrrr _test_cwds  z_BasePathTest._test_cwdcCs|j}||dSrm)racwdrrcrrrtest_cwds z_BasePathTest.test_cwdcCsX|tjd}||||t|t||t|t|| | dS)N~) rarr expanduserrrrprrrsrrrrrr _test_homes  z_BasePathTest._test_homecCstl}||j|tjt d|d<||jtjt d|d<||jWdn1sz0YdS)NZ userprofile USERPROFILEhomeHOME) rEnvironmentVarGuardrrarclearrrrr)renvrrr test_homes z_BasePathTest.test_homecCstjtd}tjtdd}||}||}||}||||||||||||tjtd}||}|t |j||t |j||t |j||t |j||t |j||t |j|dS)Nrrrfoo) rrrrrarrrrr)rZ fileA_pathZ fileB_pathrdr}rZ non_existentrrrr test_samefiles"    z_BasePathTest.test_samefilecCs$|d}||tddS)Nrr%)rarstatrrcrrrtest_empty_paths z_BasePathTest.test_empty_pathcCs|j}|d}|||tjd|d}||||d}||||d}|||||djd}|||dS)Nrr/~../~r)rarrrrabsoluterrirrrtest_expanduser_commonsz$_BasePathTest.test_expanduser_commoncCs|j}|t}|d||d|d|d|d|d|ddtr|d|d|d|d|d|dd|d|dd|d|d |d|d |d|td |d|td dS) NTrrFbahrrrrz/xyzzyu)rarrrexistsrrrirrr test_existssz_BasePathTest.test_existscCs|t}|dd.}||tj||dWdn1sL0Y|dd2}||tj|| dWdn1s0Y|djddd2}||tj || dWdn1s0YdS)Nrrzthis is file A rbthis is file Ar) buffering) rarrrhio TextIOBaserreadBufferedIOBasestrip RawIOBase)rrdrrrrtest_open_commons .2z_BasePathTest.test_open_commoncCsX|t}|dd||dd|t|djd||dddS)NrsabcdefgZsomestr)rar write_bytesr read_bytesrrrcrrrtest_read_write_bytess  z#_BasePathTest.test_read_write_bytescCsf|t}|djddd||djdddd|t|djd ||djddddS) Nruäbcdefgzlatin-1)encodingzutf-8ignore)rerrorsZbcdefgs somebytes)rar write_textr read_textrrrcrrrtest_read_write_texts  z"_BasePathTest.test_read_write_textcsX|jt}|}t|}gd}tr:|gd7}||fdd|DdS)N)rrrrr)rrrrcsh|]}t|qSrrr rrjrr rz-_BasePathTest.test_iterdir..)rariterdirsetrrr)rrditpathsrrrr test_iterdirs z_BasePathTest.test_iterdircs>|jtd}t|}fdddD}|||dS)Nrcsh|]}td|qS)rrrrrrrrz5_BasePathTest.test_iterdir_symlink..)rr)rarrrr)rrdrrrrrtest_iterdir_symlinks   z"_BasePathTest.test_iterdir_symlinkcCsb|td}|t}t|Wdn1s80Y||jjtj tj tj fdSNr) rarrOSErrornextrassertInrrENOTDIRrEINVALrrdrrrrtest_iterdir_nodir s   *z _BasePathTest.test_iterdir_nodircsfdd}jt}|d}|tjj||dg||dg||dddgts||dd dgn||dgd ts||d dgn||d gd ts||d dgn||d ddgdS)Ncs"t|fdd|DdS)Ncsh|]}t|qSrrrrrrrrzA_BasePathTest.test_glob_common.._check..rrglobrrjrrr_checksz._BasePathTest.test_glob_common.._checkrrz dir*/file* dirB/fileB dirC/fileCz*Ar)rrrz*B/*)r  dirB/linkD linkB/fileBz linkB/linkD*/fileBr ) rarrrh collectionsrIteratorrrrrrdrrrrtest_glob_commons"  z_BasePathTest.test_glob_commoncsfdd}jt}|d}|tjj||dg||ddg||dgts||ddgn||dgd||d gd td }||d d d g||dd gdS)Ncs"t|fdd|DdS)Ncsh|]}t|qSrrrrrrr/rzB_BasePathTest.test_rglob_common.._check..rrrrrr.sz/_BasePathTest.test_rglob_common.._checkrrr z*/fileAr )r zdirB/linkD/fileBr zdirA/linkC/fileBzfile*)rr r dirC/dirD/fileDrr rz*/*) rarrglobrhrrrrrrrrrtest_rglob_common-s   z_BasePathTest.test_rglob_commoncsB|j}|ttd}hd}||fdd|DdS)N*>rrr rz dirC/dirDr rrr rrrrrz dirA/linkCcsh|] }|qSrrr rdrrrRrz8_BasePathTest.test_rglob_symlink_loop..)rarrrr)rrjgivenexpectrrrtest_rglob_symlink_loopBs  z%_BasePathTest.test_rglob_symlink_loopcsd}|j}|td|gdg|R}|jddddg|fdd td D}|D]}|t||qdfd d td D}}t|D]&}|d}|D]}|t||qqdS) NZdeepr#Trrrcsg|]}qSr)rr jbasepatternrrr[rz;_BasePathTest.test_glob_many_open_files..dcsg|]}dqS)r#)rr)rrrr^r)rarrrrrr)rdepthrjrdZitersrirrrtest_glob_many_open_filesTs   z'_BasePathTest.test_glob_many_open_filescCsf|j}|t}|t|d|tdh|t|d|tdh|t|dtdS)Nrz dirA/../file*z dirA/../fileAz../xyzzy)rarrrrrirrrtest_glob_dotdotes z_BasePathTest.test_glob_dotdotcCsl|j}|td}||d}||d}||d}|d}||dtd:}tt ||_ | t t |dd Wdn1s0Y|td:}tt ||_ | t t |dd Wdn1s0Y|d td:}tt ||_ | t t |dd Wdn1s^0YdS) NZ permissionsfile1file2subdirfile3otherz os.scandirrrr)rarrtouch symlink_torpatchsortedrscandirZ return_valuerrrrr)rrjrr&r'r(r)r0rrrtest_glob_permissionsms*  8 8  z#_BasePathTest.test_glob_permissionsTcCs||}|||dSrm)resolver)rrdrstrictrrrr_check_resolves z_BasePathTest._check_resolvec Cs|j}|td}|t}|jddWdn1s<0Y||jjtj| t |jddt j td|tddd}| t |jddt j tddd|tdddd}| t |jddt j t j ddd|tdd }||||td }|||td |td d d }|||tdd |tddd }|||tdd |td d d ddd}|||tdd dddd|td d dddd}t jdkr|||td ddddn|||tddddttjdt d}|tj|t t j |t d dt t dt j |d|td ddd }|||tdd |td ddddd}|||tddddd|td dddddd}t jdkr||||ddddn|||tdddddS)NrTr3Finspamrrrrrrrrrz-dirD)rdirlinkXlinkY)rarrrr2rrrrrrprrrabspath_check_resolve_relativerrZ _longpathtempfilemkdtemprrrr_check_resolve_absolute)rrjrdrr#rrrtest_resolve_commonsh  *      z!_BasePathTest.test_resolve_commoncCs|t}|dtd|tjddtd|tjddtd|d}||jdd||dd}|jt |jdd||jd d|dddS) Nr%012Tr534F) rarrrrrrr2rr)rrdrrrrrtest_resolve_dots  z_BasePathTest.test_resolve_dotcCs|t}|}|}t||Wdn1s<0Yt|t|||||Wdn1s0YdSrm)rarrrrr2r)rrdrZit2rrr test_withs z_BasePathTest.test_withcCsd|td}|j}|d@}||||j||dB}||||j|dS)Nrim)rarrst_moderr)rrdmodeZnew_moderrr test_chmods   z_BasePathTest.test_chmodcCsZ|td}|}|||||jdA||j|j|||dS)NrrH)rarrrrrIrrrrdstrrr test_stats z_BasePathTest.test_statcCs*|td}|}|||dS)Nr)rarrrlstatrLrrr test_lstat sz_BasePathTest.test_lstatcCs*|td}|}|||dSr)rarrrrOrLrrrtest_lstat_nosymlinksz"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testcCs^|td}|j}zt|j}Wn tyH|d|Yn0| || dS)Nrz4user %d doesn't have an entry in the system database) rarrst_uidpwdgetpwuidpw_nameKeyErrorrrr)rrduidrrrrrs   z_BasePathTest.test_ownerz&the grp module is needed for this testcCs^|td}|j}zt|j}Wn tyH|d|Yn0| || dS)Nrz5group %d doesn't have an entry in the system database) rarrst_gidgrpgetgrgidgr_namerVrrr)rrdgidrrrrr!s   z_BasePathTest.test_groupcCs2|td}|||j||jdSr)rarunlinkrrrcrrr test_unlink,s z_BasePathTest.test_unlinkcCs*|td}||j|jdddS)NfileAAAT) missing_ok)rarrr]rcrrrtest_unlink_missing_ok2s z$_BasePathTest.test_unlink_missing_okcCsH|td}|D] }|q|||j||jdS)Nr)rarrr]rmdirrrrrrr test_rmdir7s    z_BasePathTest.test_rmdirlinkzos.link() is not presentc Cs|t}|d}|j}|dd}z||Wn2tyh}z|d|WYd}~n d}~00||j||tj ||d| |jt d}|||t|j|| |jdS)NrrfileAAz os.link(): %sTr_) rarrst_sizelink_toPermissionErrorrrrrrrrel_join)rrjrdsizererrrr test_link_to?s   $  z_BasePathTest.test_link_tozos.link() is presentcCsV|t}|d}|dd}|t||Wdn1sH0YdS)Nrrre)rarrrrgrrjrdrrrrtest_link_to_not_implementedSs    z*_BasePathTest.test_link_to_not_implementedcCs|t}|d}|j}|dd}||}|||||j|||jtd}||}|||||t|j|||jdS)Nrrrer_) rarrrfrenamerrrir)rrjrdrjrZ renamed_prZ renamed_qrrr test_rename\s       z_BasePathTest.test_renamecCs|t}|d}|j}|dd}||}|||||j|||jtdd}||}|||||t|j|||jdS)Nrrrerr) rarrrfr rrrir)rrjrdrjrZ replaced_prZ replaced_qrrr test_replacems        z_BasePathTest.test_replacecCs|t}||d|d||d|d||d|d|t|dWdn1s0YdS)Nrrrrrr)rarrreadlinkrrrrrr test_readlink~s  z_BasePathTest.test_readlinkcCs|t}|d}||||||}|j}|j}t t ||d|df||}| |j|| |j||d}|||jddd|||j t|jdddS)NZnewfileA ZnewfileBiF)rJexist_okru)rarrrr,rrst_mtime st_mtime_nsrutimerpr.rr)rrjrdrMZ old_mtimeZ old_mtime_nsrrrtest_touch_commons$ z_BasePathTest.test_touch_commoncCs\|t}|d}||d$}||dWdn1sN0YdS)Nrrr)rarr,rrrr)rrjrdrrrrtest_touch_nochanges   z!_BasePathTest.test_touch_nochangecCs|t}|d}||||||||t}|Wdn1sl0Y| |j j t j dS)NZnewdirA) rarrrrris_dirrrrrrEEXIST)rrjrdrrrr test_mkdirs  &z_BasePathTest.test_mkdircCs^|tdd}|||t}|Wdn1sD0Y||jj t j |jdd| || | |t}|jddWdn1s0Y||jj t j t|j}|tdd}|jddd| || | tjdkr@|t|jd |@|t|jj|dS) NZnewdirBnewdirCTrZnewdirDZnewdirEimrim)rarrrrrrrrrrrr|r}rS_IMODErIrrr)rrdrrJrrrtest_mkdir_parentss& &  * z _BasePathTest.test_mkdir_parentscCs|td}|j}|||||t}| Wdn1sZ0Y| |j j t j |j dd||| |j|dS)NrTrv)rarrst_ctimerrr|rFileExistsErrorrrrrr})rrdst_ctime_firstrrrrtest_mkdir_exist_oks   & z!_BasePathTest.test_mkdir_exist_okcCs|td}|||t}|Wdn1sB0Y||jj t j |d}|jdd| j }|||t}|jddWdn1s0Y||jj t j |jddd|||| j |dS)NrrTrrru) rarrrrrrrrrr}rr)rrdrrrrrtest_mkdir_exist_ok_with_parents  &   *z-_BasePathTest.test_mkdir_exist_ok_with_parentcCs2|djdd|djddddS)NrTrvr)rar2rrxrrrtest_mkdir_exist_ok_rootsz&_BasePathTest.test_mkdir_exist_ok_rootcCspdD]}||d}|sq.q|d|t$|ddjddWdn1sb0YdS)NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't existchildrTr)rar|rrrr)rr#rdrrrtest_mkdir_with_unknown_drives  z+_BasePathTest.test_mkdir_with_unknown_drivecCs|tdd}|||t}|jddWdn1sH0Y||jj t j |t}|jdddWdn1s0Y||jj t j dS)NrrTrr rarrrrrrrrrr}rrrrtest_mkdir_with_child_files * ,z(_BasePathTest.test_mkdir_with_child_filecCs|td}|||t}|Wdn1sB0Y||jj t j |t}|jddWdn1s0Y||jj t j dS)NrTrvrrrrrtest_mkdir_no_parents_files  & *z(_BasePathTest.test_mkdir_no_parents_filec stdD]ډ|td}||dfdd }fddtdDt|d d }z>td ||jd d dWdn1s0YWn"t y| t |Yn0| t || |qdS)N zdirCPC%drcs6t|}r&t|||t||dSrm)rppoprradd)rrJ)concurrently_createdr rrmy_mkdirs   zE_BasePathTest.test_mkdir_concurrent_parent_creation..my_mkdircsg|]}td|>@qS)r)bool)r n) pattern_numrrr!rzG_BasePathTest.test_mkdir_concurrent_parent_creation..Zdir1Zdir2zpathlib._normal_accessor.mkdirTFr)r)rrarrrrrr.rrrrpZ assertNotInr)rrdrZp12r)rr rr%test_mkdir_concurrent_parent_creations   0 z3_BasePathTest.test_mkdir_concurrent_parent_creationcCs|t}|d}|dd}|||||||||dd}|t||||||||| |d}|dd}|j|dd||||||| | | t | dS) NrrZlinkAAZlinkAAArZlinkAAAATr) rarr-rrrrOrprr|rrr)rrjtargetrdrrrtest_symlink_to-s$     z_BasePathTest.test_symlink_tocCs|t}||d||d||d||ddtr||d||d||dd||d d||d ddS) NrrrrrrrFudirAzdirA)rarrr|rrrrrrrrr test_is_dirEs z_BasePathTest.test_is_dircCs|t}||d||d||d||ddtr||d||d||d||dd ||d d dS) NrrrrrrrfileAFfileA)rarris_filerrrrrrrrr test_is_fileRs z_BasePathTest.test_is_filecCs|t}|d}||d||d||d||dd||tr||d||dd||d ddS) Nrrrrrru/Fz/)rarris_mountrrrrr)rrjRrrr test_is_mount_s  z_BasePathTest.test_is_mountcCs|t}||d||d||d||ddtr||d||d||d||dd ||d d tr||d d ||d d dS) NrrrrrrrrFrulinkAzlinkA) rarr is_symlinkrrrrrrrrrrtest_is_symlinkms z_BasePathTest.test_is_symlinkcCs|t}||d||d||d||dd||dd||dddSNrrrrrFr)rarris_fiforrrrrrtest_is_fifo_false}s z _BasePathTest.test_is_fifo_falsemkfifozos.mkfifo() requiredc Cs|td}ztt|Wn2tyP}z|d|WYd}~n d}~00||| | | | | |tdd| |tdddS)NZmyfifozos.mkfifo(): %su myfifoFzmyfifo) rarrrrprhrrrr is_socketrrr)rrjrkrrrtest_is_fifo_trues $z_BasePathTest.test_is_fifo_truecCs|t}||d||d||d||dd||dd||dddSr)rarrrrrrrrrtest_is_socket_falses z"_BasePathTest.test_is_socket_falseAF_UNIXzUnix sockets requiredc Cs|td}ttjtj}||jz|t|WnLt y}z4t |t s`dt|vrr| dt|WYd}~n d}~00| |||||||tdd||tdddS)NZmysockzAF_UNIX path too longzcannot bind Unix socket: u mysockFzmysock)rarsocketr SOCK_STREAMrclosebindrpr isinstancerhrrrrrrrr)rrjsockrkrrrtest_is_socket_trues    (z!_BasePathTest.test_is_socket_truecCs|t}||d||d||d||dd||dd||dddSr)rarris_block_devicerrrrrrtest_is_block_device_falses z(_BasePathTest.test_is_block_device_falsecCs|t}||d||d||d||dd||dd||dddSr)rarris_char_devicerrrrrrtest_is_char_device_falses z'_BasePathTest.test_is_char_device_falsecCsv|d}|s|d||||||||dd||dddS)Nz /dev/nullz/dev/null requiredu /dev/nullFz /dev/null) rarrrrrrrrrrrrrtest_is_char_device_trues  z&_BasePathTest.test_is_char_device_truecCsP|td}tdtjdD].}t||}t|}|||qdS)Nrrr) rarrrrrrrr)rrdr r r}rrrr s    z"_BasePathTest.test_pickling_commoncCsJ|j}|d}|d}||jd|jd||jd|jddS)Nz /usr/bin/fooz/usr/local/binrrr)rarrrqrmrrrtest_parts_internings z"_BasePathTest.test_parts_interningc Cs|t}|tjddtd|tjddtd|tjddtd||td|d}||||t |t|d}||||t |t|d}||||t |t|d}||||t |tt }t tz|d}||||t |t|d}||||t |t|d}||||t |t|d}||||t |tWt |n t |0dS)NZlink0Zlink1Zlink2Zlink3) rarrrrrr2rrrprchdir)rZ link0_targetrjrdZold_pathrrr_check_complex_symlinkssB              z%_BasePathTest._check_complex_symlinkscCs|tdSrm)rrrxrrrtest_complex_symlinks_absolute sz,_BasePathTest.test_complex_symlinks_absolutecCs|ddS)Nr%)rrxrrrtest_complex_symlinks_relative sz,_BasePathTest.test_complex_symlinks_relativecCs|tjdddS)Nrr)rrrrrxrrr&test_complex_symlinks_relative_dot_dot sz4_BasePathTest.test_complex_symlinks_relative_dot_dotN)T)[r.r/r0__doc__rerrrrrrrrrrrrrrrrrrrskip_unless_symlinkrrrrrr$r%r1r4r<r?r@rFrGrKrNrPrQunittest skipUnlessrSrrYrr^rarchasattrrlskipIfrnrprqrsrzr{r~rrrronly_ntrrrrrrr only_posixrrrrrrrrrrr rrrrrrrrrr<s           $  ;                          )  rc@s2eZdZejZddZddZddZddZ d S) PathTestcCs||jt|jdSrm)rrrarprxrrrtest_class_getitem szPathTest.test_class_getitemcCs0|d}|t|tjdkr$tjntjdSr)rarrrsrrrFrrrcrrrr s  zPathTest.test_concrete_classcCs,tjdkr|ttjn|ttjdS)Nr)rrrrrFrrrxrrrtest_unsupported_flavour s z!PathTest.test_unsupported_flavourcCsF|}|tdt|dWdn1s80YdS)NzUnacceptable patternr)raZassertRaisesRegexrrrrcrrrtest_glob_empty_pattern! sz PathTest.test_glob_empty_patternN) r.r/r0rFPathrarrrrrrrrr s rc@seZdZejZddddZddZddZd d Z e j d d Z d dZ ddZeeeddddZeejdkdddZdS) PosixPathTestTr5cGsF|j|}|tt||Wdn1s80YdSrm)rar RuntimeErrorprintr2)rr3rtrrrr_check_symlink_loop+ s  z!PosixPathTest._check_symlink_loopcCstd}|tj||t}|ddWdn1sF0Yttd}|t |j dtd|ddWdn1s0Yttd}|t |j ddS)Nrnew_filerother_new_file) rumaskrrarrrrrrrIrZold_maskrdrMrrrtest_open_mode0 s   zPosixPathTest.test_open_modec CsPt}z6td|d}|t|dWt|n t|0dS)Nrr7z/spam)rrrrarrpr2)rZcurrent_directoryrdrrrtest_resolve_root> s   zPosixPathTest.test_resolve_rootcCstd}|tj||t}|dttd}|t |j dtd|dttd}|t |j d|djdd ttd}|t |j ddS) NrrrrrrZmasked_new_filei)rJ) rrrrarr,rrrrrIrrrrtest_touch_modeG s     zPosixPathTest.test_touch_modecCstdtd|tdtdtd|tdtdtd|td|jtddddttd td |td ttd td |td ttd td |td |jtd ddddS)Nz linkX/insider9r:zlinkZ/../linkZZlinkZrFr5z linkU/insideZlinkUZlinkVzlinkW/../linkWZlinkW)rrrrrrxrrrtest_resolve_loopV s      zPosixPathTest.test_resolve_loopcCsX|j}|t}t|d}tts,tn|}||||t|dtdS)NFILEazFILEa*)rarrrrfs_is_case_insensitiverrrjrdrrrrr test_globk s  zPosixPathTest.test_globcCsZ|j}|td}t|d}tts.tn|}||||t|dtdS)NrFILEdzFILEd*)rarrrrrrrrrr test_rglobs s   zPosixPathTest.test_rglobgetpwallz%pwd module does not expose getpwall()cCs|j}tdddl}|t}|j}|j dp:d}| D]&}|j}|j d}||krD|rDqtqD|}|}|d}|d|d} |d|d} |d|d} |d|d} |d } |d }t ,}| d d| |||d | | ||d | | ||d | | | | | | | | | |t|jd |d <| ||d| | ||d | | ||d | | | | | | | | | |t|jWdn1s 0YdS)NrSrrz ~/Documentsrz /Documentsrrrz~fakeuser/DocumentsrZ Documentsz/tmpz/tmp/Documents)rar import_modulerSrTrgetuidrUpw_dirrstriprrrrrrr)rrjrSZpwdentusernameuserhomeZ othernameZ otherhomep1p2p3p4p5p6Zp7rrrrtest_expanduser{ sJ      zPosixPathTest.test_expanduserdarwinz1Bad file descriptor in /dev/fd affects only macOSc Cszxttdddd}|s,|d|D]D}||||| | | | q0Wn<t y}z$|jtjkr|dWYd}~n d}~00dS)Nz/dev/fdrrz.no file descriptors - issue was not reproducedz Bad file descriptor not handled.)rrFrrrrr|rrrrrrrrEBADFZfail)rZfile_descriptorsrrkrrrtest_handling_bad_descriptor s"   z*PosixPathTest.test_handling_bad_descriptorN)r.r/r0rFrrarrrrrrrrrrrrrSrrsysplatformrrrrrr' s"    - rc@s*eZdZejZddZddZddZdS)WindowsPathTestcCs|j}|t}|t|d|tdh|t|d|tdh|ttt|d|dh|ttt|d|dhdS)NrrzF*az\FILEaz\fileA)rarrrrmaprprirrrr s $zWindowsPathTest.test_globcCsV|j}|td}|t|d|tdh|ttt|d|dhdS)Nrrrz \dirD\FILEd)rarrrrrrprirrrr s zWindowsPathTest.test_rglobc sljtFdddddddddd<ddd d d d tjtjtjf d d}dd<|dd<dd<|dddddd<|dd<|Wdn1s^0YdS)NrrHOMEPATH HOMEDRIVEaliceUSERNAMEz~/My Documentsz~alice/My Documentsz~bob/My Documentsz/~/My Documentszd:~/My Documentsrcsdddtjdd<dddS)NrzC:/Users/alice/My DocumentsrzC:/Users/bob/My Documents)rrrrrVr rjrrrrrrrrrrr, s    z.WindowsPathTest.test_expanduser..checkzC:\Users\alicezC:\z Users\alicez C:\Users\eve)rarrrrrrrr9rrrr s>       zWindowsPathTest.test_expanduserN) r.r/r0rFrrarrrrrrrr src@s.eZdZdZGdddZddZddZdS) CompatiblePathTestz| Test that a type can be made compatible with PurePath derivatives by implementing division operator overloads. c@s(eZdZdZddZddZddZdS) zCompatiblePathTest.CompatPathz Minimum viable class to test PurePath compatibility. Simply uses the division operator to join a given string and the string value of another object with a forward slash. cCs ||_dSrm)string)rrrrr__init__ sz&CompatiblePathTest.CompatPath.__init__cCst||jd|Srrsrrr*rrr __truediv__ sz)CompatiblePathTest.CompatPath.__truediv__cCst||d|jSrrrrrr __rtruediv__ sz*CompatiblePathTest.CompatPath.__rtruediv__N)r.r/r0rrrrrrrr CompatPath srcCsltd|d}|||j||jd|ttddWdn1s^0YdS)Ntestrightz test/rightrt)rFrrrhrrrrrresultrrr test_truediv s  zCompatiblePathTest.test_truedivcCsl|dtd}|||j||jd|tdtdWdn1s^0YdS)Nleftrz left/testrt)rrFrrhrrrrrrrr test_rtruediv) s  z CompatiblePathTest.test_rtruedivN)r.r/r0rrrrrrrrr s r__main__)0collections.abcrrrrrrFrrrr=rrrrZ test.supportrrrYrS ImportErrorobjectrZTestCaser1rHrZr r&rrrealpathrrrirrrrrrrrrrrr.mainrrrrs|   )$B L    [G)