bgdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZddlmZddlmZmZddlmZejd kZGd d e jeZGd d eZGddeZeje dGddeZGddeZGddeZGddeZ GddeZ!Gdde!Z"GddeZ#Gdd e#Z$Gd!d"eZ%Gd#d$e%Z&Gd%d&ejZ'Gd'd(e jZ(e)d)krej*d*+dSdS),z Unittests for fake_pathlib. As most of fake_pathlib is a wrapper around fake_filesystem methods, the tests are there mostly to ensure basic functionality. Note that many of the tests are directly taken from examples in the python docs. N) namedtuple)mock) fake_pathlibfake_filesystemfake_filesystem_unittestfake_os)OSType)IS_PYPYis_root)RealFsTestMixinwin32c8eZdZejdkZddZdZdZdS)RealPathlibTestCaser runTestcntj||tj|dSN)rTestCase__init__r )self methodNames q/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyfakefs/tests/fake_pathlib_test.pyrzRealPathlibTestCase.__init__*s2 )224DDD &&&&&cNtj|d|_t|_|s4||j|_|t|_ tj |_ t|_t|_ dSr) r setUp filesystemosreal_os use_real_fs setUpPyfakefsfscreate_basepathpathlibPathpathopenrs rrzRealPathlibTestCase.setUp.sd### !! #    "gDO  " " " L  rcdS)NFr&s rrzRealPathlibTestCase.use_real_fs;surN)r) __name__ __module__ __qualname__sysplatform is_windowsrrrr(rrrr'sR(J''''   rrceZdZdZdZdZdZeje ddZ eje ddZ d S) FakePathlibInitializationTestc|d}tr|t||jj|t||jj||j|rN| t5|j ddddS#1swxYwYdS||j dS|t||jj |t||jj||j|rN| t5|jddddS#1swxYwYdS||jdS)z(Make sure tests for class type will workz/testN) r$r. assertTrue isinstancer" WindowsPathPureWindowsPath PurePosixPathr assertRaisesNotImplementedError PosixPathrr$s rtest_initialization_typez6FakePathlibInitializationTest.test_initialization_type@sqyy!!  < OOJtT\-EFF G G G OOJtT\-IJJ K K K OODL6688 9 9 9!! :&&':;;--L**,,,------------------ 6 6 8 899999 OOJtT\-CDD E E E OOJtT\-GHH I I I OODL88:: ; ; ;!! <&&':;;//L,,...////////////////// 8 8 : :;;;;;s$C99C=C=(HHHcD||dddd|d|||d|||d|d|d||dd z d z |d d S) zTBasic initialization tests - taken from pathlib.Path documentation. /foobarbaz /foo/bar/baz.foo/bar/etczinit.drebootz/etc/init.d/rebootN assertEqualr$r&s rtest_init_with_segmentsz5FakePathlibInitializationTest.test_init_with_segmentsWs 3ue<W>WXXX diinn555  IIdii&& %(8(8 9 9499Y;O;O     IIf   (8 3 II* + +     rc||d|d||d|d||d|d||ddd|dd S) lTests for collapsing path during initialization. Taken from pathlib.PurePath documentation. zfoo//barrCz foo/./barz foo/../barrD/usrlib64z /usr/lib64N)rGr$assertNotEqualr&s rtest_init_collapsez0FakePathlibInitializationTest.test_init_collapsees :.. )0D0DEEE ;//91E1EFFF DIIl33TYYy5I5IJJJ 667;;TYY|=T=TUUUUUrc 6|jjj}|||jjdddz}||j|dddf||jd||j|||j|||j d||j d||j d||j |||jjddz||j d|||jjddz||j d||dz||j d ||dS) Nr>r?setup.pysetup.pyr)rr$sepjoinrGpartsdriverootanchornamestemsuffixparentparents)rrVr$s rtest_path_partsz-FakePathlibInitializationTest.test_path_partsnsglyytw|00zJJJKK c5%%DEEE R((( C((( c*** J/// G,,, e,,, diidgl6G6Gu6U6U0U&V&VWWW  LOTYYsTW\->->ue-L-L'LMM    a$))C%K*@*@AAA a$))C..99999rPOSIX specific behaviorcb||d||d||ddSN/a/bza/bzd:/br2r$ is_absolute assertFalser&s rtest_is_absolute_posixz4FakePathlibInitializationTest.test_is_absolute_posixs  &))5577888 5))5577888 6**668899999rWindows specific behaviorcb||d||d||ddSrd)rhr$rgr2r&s rtest_is_absolute_windowsz6FakePathlibInitializationTest.test_is_absolute_windowss 6**6688999 5))5577888  &))557788888rN) r)r*r+r;rHrNraunittestskipIfr.rirlr(rrr0r0?s<<<.    VVV:::"X_Z!:;;::<;: X_^%@AA99BA999rr0ceZdZdZdS)RealPathlibInitializationTestcdSNTr(r&s rrz)RealPathlibInitializationTest.use_real_fstrNr)r*r+rr(rrrprp#rrprjcVeZdZdZdZdZeje ddZ dS)&FakePathlibInitializationWithDriveTestcD||dddd|d|||d|||d|d|d||dd z d z |d d S) zJBasic initialization tests - taken from pathlib.Path documentationc:/r>r?r@zc:/foo/bar/bazrBrCzc:/Usersjohndatazc:/Users/john/dataNrFr&s rrHz>FakePathlibInitializationWithDriveTest.test_init_with_segmentss  IIeUE5 1 1499=M3N3N    diinn555  IIdii&& %(8(8 9 9499Y;O;O     IIj ! !F *V 3 II* + +     rc||dd|d||dd|ddS)rJz c:/Windowszd:bar/Program Filesc:/Program FilesNrFr&s rrNz9FakePathlibInitializationWithDriveTest.test_init_collapsesx <99499W;M;MNNN  IIl$4 5 5 II( ) )     rc ||jjddd}||jd||jd||jd||jd||jd||j d||j d||j ||jjdd||j d||jjdd||j d |ddS) Nd:python scriptsrP)rrrPrQrRrSrrT) r$rrWrGrXrYrZr[r\r]r^r_r`r:s rraz6FakePathlibInitializationWithDriveTest.test_path_partssyy**41A:NNOO %IJJJ T*** B''' d+++ J/// G,,, e,,,  K47<#4#4T;K#L#LMM     LO IIdgl''.>?? @ @    a$))D//:::::rzWindows-specifc behaviorc||d||d||d||ddS)Nzc:/a/brec:z //some/sharerfr&s rtest_is_absolutez7FakePathlibInitializationWithDriveTest.test_is_absolutes  (++7799::: 6**6688999 44466777  .11==??@@@@@rN) r)r*r+rHrNrarmrnr.rr(rrrwrwst       ;;;$X_^%?@@AAA@AAArrwceZdZdZdS)&RealPathlibInitializationWithDriveTestcdSrrr(r&s rrz2RealPathlibInitializationWithDriveTest.use_real_fsrsrNrtr(rrrrrurrceZdZdZdZeje ddZdZ dZ dZ dZ eje jd kd d Zd Zd ZdS)FakePathlibPurePathTestz.Tests functionality present in PurePath class.c|||d||d||d||ddSNz/devr=COM1znul.txt)check_posix_onlyrhr$ is_reservedr&s rtest_is_reserved_posixz.FakePathlibPurePathTest.test_is_reserved_posixs  6**6688999 33355666 6**6688999 9--99;;<<<<>??? ;//55h??@@@  '**0099::: 8,,227;;<<<< >z J J II- . .     z * * 3 3 IIe   & &z 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s>)B44B8;B8cB||dd|d||dd|ddS)Nrz.bz2zc:/Downloads/pathlib.tar.bz2READMEz.txtz README.txt)rGr$ with_suffixr&s rtest_with_suffixz(FakePathlibPurePathTest.test_with_suffixs  II3 4 4 @ @ H H II4 5 5     IIh   + +F 3 3TYY|5L5L     rN)r)r*r+__doc__rrmrnr.rrrrrr, version_inforrrr(rrrrs88===X_^%@AA<<BA<      ===444X_S%.0RSS66TS6 333     rrceZdZdZdS)RealPathlibPurePathTestcdSrrr(r&s rrz#RealPathlibPurePathTest.use_real_fsrsrNrtr(rrrrrurrcVeZdZfdZdZdZdZdZdZdZ e j e dd Z e j e d d Ze j e d d ZdZe j ejdkddZdZdZdZdZdZdZdZxZS)!FakePathlibFileObjectPropertyTestcTtt||ddd|_||jd||dd |n#tj $rYdSwxYw| |d|dd|d|_ | |j |j| |d|dd| |d |ddddS) Nhomejanetest.pysdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacontentsrzbroken_dir_linknonebroken_file_link) superrr make_path file_path create_file create_dirskip_if_symlink_not_supportedrmSkipTestcreate_symlinkfile_link_path)r __class__s rrz'FakePathlibFileObjectPropertyTest.setUps /66<<>>> BB *=== vv66777   . . 0 0 0 0     FF  DNN622DNN664R4RSSS"nnY77 D/@@@  NN, - -t~~ff/M/M     NN- . . NN669 5 5     s B B32B3c 2||||j|||dd|||ddd|||d|||j|||d|||ddS)Nrrtestrzrr)rr2r$rexistsrrhrr&s r test_existsz-FakePathlibFileObjectPropertyTest.test_exists2s **,,,  $.1188::;;;  $.."@"@AAHHJJKKK 4>>&&&#I#IJJQQSSTTT  $.."8"899@@BBCCC  $"566==??@@@ 4>>2C#D#DEELLNNOOO 4>>2D#E#EFFMMOOPPPPPrc||||j|||d|||d|||j|||d|||ddS)N home/janerzrr)rrhr$ris_dirr2rrr&s r test_is_dirz-FakePathlibFileObjectPropertyTest.test_is_dir<sU **,,, 4>2299;;<<<  $.."="=>>EEGGHHH  $.."8"899@@BBCCC 4#677>>@@AAA 4>>2C#D#DEELLNNOOO 4>>2D#E#EFFMMOOPPPPPrc||||d|||d|||d|||j|||d|||ddSNzhome/jane/test.pyrrzrr)rr2r$ris_filerhrr&s r test_is_filez.FakePathlibFileObjectPropertyTest.test_is_fileEs` **,,,  $..1D"E"EFFNNPPQQQ 4>>+#>#>??GGIIJJJ 4>> #9::BBDDEEE  $"566>>@@AAA 4>>2C#D#DEEMMOOPPP 4>>2D#E#EFFNNPPQQQQQrc||||d|||d|||d|||j|||d|||ddSr)rrhr$r is_symlinkr2rr&s rtest_is_symlinkz1FakePathlibFileObjectPropertyTest.test_is_symlinkNs\ **,,, 4>>2E#F#FGGRRTTUUU 4>>+#>#>??JJLLMMM  $.."8"899DDFFGGG  $"566AACCDDD  $..1B"C"CDDOOQQRRR  $..1C"D"DEEPPRRSSSSSrc||j|j}||j}||jtjz| |jtj z| |j |j | |j d| |j|j| |tjt!|jdS)Nd)rrstatrr$rrhst_modeS_IFDIRr2S_IFREGrGst_inost_sizest_mtimeST_MTIMEint)r file_stat stat_results r test_statz+FakePathlibFileObjectPropertyTest.test_statWs **,,,GLL00 ii 34499;;  ,t|;<<<  +dl:;;; +Y-=>>> ,c222 -y/ABBB T]3S9K5L5LMMMMMrc||j|j}||j}||jtjz||jtj z| |j |j | |j || |j |j dSr)rrlstatrr$r2rrrS_IFLNKrGrrr)r expected_size link_statrs r check_lstatz-FakePathlibFileObjectPropertyTest.check_lstatcs **,,,GMM$"566 ii 344::<<   +dl:;;;  +dl:;;; +Y-=>>> ,m<<< -y/ABBBBBrrbcT|t|jdSr)rlenrr&s rtest_lstat_posixz2FakePathlibFileObjectPropertyTest.test_lstat_posixns& T^,,-----rrjcX||ddS)Nr)rrr&s rtest_lstat_windowsz4FakePathlibFileObjectPropertyTest.test_lstat_windowsrs. **,,, rzLinux specific behaviorcJ||j|j}||jtjdz|j|j}||jtj dzdS)Ni) check_linux_onlyrrrrGrrrrrrrrs r test_chmodz,FakePathlibFileObjectPropertyTest.test_chmodws GLL00  *DL5,@AAAGMM$"566  *DL5,@AAAAArc||j|j}|j|j}t |jdsb|t5| |j dddddS#1swxYwYdS| |j d| |j tjdz| |j dztjdzdS)Nlchmod$r)rrrrrrhasattrrr7r8r$rrGrrrrs r test_lchmodz-FakePathlibFileObjectPropertyTest.test_lchmods` **,,,GLL00 GMM$"566 t|X.. Q""#677 = = $-..55e<<< = = = = = = = = = = = = = = = = = = IId) * * 1 1% 8 8 8   Y. u0D E E E   Y.94<%;O P P P P Ps.B==CCr z+follow_symlinks argument new in Python 3.10c||j|j}|j|j}|jj|jjvstrd| t5| |jddddddS#1swxYwYdS| |jdd| |j tjdz| |j dztjdzdS)NrFfollow_symlinksrrr)rrrrrrchmodsupports_follow_symlinksr r7r8r$rGrrrrs rtest_chmod_no_followsymlinksz>FakePathlibFileObjectPropertyTest.test_chmod_no_followsymlinkss **,,,GLL00 GMM$"566 7= @ @ @G @""#677 S S $-..44UE4RRR S S S S S S S S S S S S S S S S S S IId) * * 0 0 0 N N N   Y. u0D E E E   Y.94<%;O P P P P Ps 0C  C C c :||dd||dd|j|d||||jj|d|||jj ddd||jj|dddS)NantoinedocsrP..) rrrrchdirassert_equal_pathsr$resolverealpathrWr&s r test_resolvez.FakePathlibFileObjectPropertyTest.test_resolvesD y&99:::  :>>???  dnnY//000  IIKK   ! ! IIdgl++DNN9,E,EFF G G     IIdgl''jAA B B J J L L IIdgl++DNN9j,Q,QRR S S     rc||d}|jj|d}|||j|dts:|tj ||j dS| d|| j dSNsome_dir some_filer)rrrr$rWrrr assert_raises_os_errorerrnoEACCESrrGr)rdir_pathrs r test_stat_file_in_unreadable_dirzBFakePathlibFileObjectPropertyTest.test_stat_file_in_unreadable_dirs >>*--GL%%h <<  ###  h&&&yy E  ' ' dii 6J6J6O P P P P P   Q ) 4 4 9 9 ; ; C D D D D DrcF||d}|jj|d}|||j|d||}ts(| tj t|dStt|d}||ddSr)rrrr$rWrriterdirr rrrliststrr2endswith)rrritr$s rtest_iterdir_in_unreadable_dirz@FakePathlibFileObjectPropertyTest.test_iterdir_in_unreadable_dirs >>*--GL%%h <<  ###  h&&& YYx ( ( * *yy 8  ' ' dB ? ? ? ? ?tBxx{##D OODMM+66 7 7 7 7 7rc||dddd}|||dS)Nz/pathtofilezthis can not exist)r$rrGr r:s rtest_resolve_nonexisting_filez?FakePathlibFileObjectPropertyTest.test_resolve_nonexisting_filesJyyv?STTUU t||~~.....rcH|d}|||j|||j||jj|dS)Nr)rrrr r r$cwdr)rrs rtest_cwdz*FakePathlibFileObjectPropertyTest.test_cwds>>&)) !!!  h  IMMOOTYYtw|'<'> #9::AACCDDD 4>>&&&#I#IJJQQSSTTTTTrcX||d|t5||dddddn #1swxYwY||ddd||jj |dddS)Nr>bar.txtw) rrr7OSErrorr$r%closer2rrr&s r test_openz*FakePathlibPathFileOperationTest.test_opens' u--...   w ' ' ? ? IIdnnUI66 7 7 < < > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $.. 223388==CCEEE  ++DNN5),L,LMMNNNNNsrrrr$rG read_textrrs rtest_read_textz/FakePathlibPathFileOperationTest.test_read_textsl  44uEEEIIdnn[99::  ,,..66666r)r z%is_junction method new in Python 3.12c||dd||d}||dSr@)rrr$rh is_junctionrDs rtest_is_junctionz1FakePathlibPathFileOperationTest.test_is_junctionsl  44uEEEIIdnn[99::  ..0011111rc||ddd||d}||dddS)NrAu ерундаcyrillic)rencodingrLrBrDs rtest_read_text_with_encodingz=FakePathlibPathFileOperationTest.test_read_text_with_encoding s~  NN; ' '.:    IIdnn[99::  ,,j,AA>RRRRRrc.|d}||}|td||jj|||ddS)NrAr>)rr$ write_textrr2rrcheck_contentsr path_namers rtest_write_textz0FakePathlibPathFileOperationTest.test_write_texts~NN;// IIi(( SZZ(((  ++I66777 Iu-----rc>|d}||}|dd||jj|||dddS)NrAuανοησίεςgreekrM)rr$rPr2rrrQencoderRs rtest_write_text_with_encodingz>FakePathlibPathFileOperationTest.test_write_text_with_encodingsNN;// IIi(( /'BBB  ++I66777 I'9'@'@'I'IJJJJJrrz#newline argument new in Python 3.10c||d}|dd||d|dd||d|dd||d|dd ||d dS) Nrz1 2 3 4rQ)newlines1 2 3 4 z s 1 2 3 4 s1 2 3 4)r$rrPrQr:s rtest_write_with_newline_argz?????rcl|dd}||d|dd}|||||jj|||ddS)Nr>r:rrbaz.txt)rrr$renamerhrrrQ)r file_name new_file_names r test_renamez,FakePathlibPathFileOperationTest.test_rename;sNN5)44  V444ui88  )##M222 ,,Y77888 M622222rc2||ddd||ddd||dd|dd||jj|dd||ddddS)Nr>r:rrr?zold.txtreplaced)rrr$r.rhrrrQr&s r test_replacez-FakePathlibPathFileOperationTest.test_replaceCs y99FKKK y99JOOO $.. 2233;; NN5) , ,    ,,T^^E9-M-MNNOOO DNN5)<r:rr)rrr2rr$runlinkrhrDs r test_unlinkz,FakePathlibPathFileOperationTest.test_unlinkLsNN5)44  V444  ++I66777 )##%%% ,,Y7788888rc||d|dd}||d||d||j|jtj dz|j |ddS)Nr>r:r)moderQr) rrr$touchrQr2rrrrr)rris rtest_touch_non_existingz8FakePathlibPathFileOperationTest.test_touch_non_existingSs u--...NN5)44  )"""... Ir***  Y//79MNNN  ie ,,,,,rc,|dd}||d||}|tj|jd|||ddS)Nr>r:rrFexist_ok)rrr$rrEEXISTrtrQ)rrirs rtest_touch_existingz4FakePathlibPathFileOperationTest.test_touch_existing[sNN5)44  V444IIi((  ##EL)/E#RRR Iv.....rc 2|dd}|||dd}|||t5||dd|dddddn #1swxYwY||}|dd}|t5||dddn #1swxYwY|t5|||dddn #1swxYwY||||||||||dddd||||dddddS)Nr>r:rgotherz other.txtr )rrr7r<r$samefilerhr2)rri file_name2r$ other_names r test_samefilez.FakePathlibPathFileOperationTest.test_samefilecsNN5)44  ###^^E955  $$$   w ' '   IIdnnUG44 5 5 > >uk22                  yy##^^E;77   w ' ' & & MM* % % % & & & & & & & & & & & & & & &   w ' ' 1 1 MM$))J// 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 z22333 tyy'<'<==>>>  dnnUD%&S&STTUUU  MM$))DNN5$y$Q$QRR S S     s71ACCCEEE%)FF!Fc||dd}|||d}||}||||jj|||dS)Nr>r: link_to_bar) rrrr$ symlink_tor2rrrrri link_namer$s rtest_symlink_toz0FakePathlibPathFileOperationTest.test_symlink_toys **,,,NN5)44  ###NN=11 yy##  """  ++I66777 ))*****rrzlink_to new in Python 3.8zlink_to removed in Python 3.12c||dd}|||d|j|j|d}||}||| |jj || | |d|j|jdSNr>r:rTrrU) rrrrGrrst_nlinkr$link_tor2rrhrrs r test_link_toz-FakePathlibPathFileOperationTest.test_link_tos **,,,NN5)44  ### DGLL33<===NN=11 yy## Y  ++I66777 **+++ DGLL33<=====rzhardlink_to new in Python 3.10c||dd}|||d|j|j||d}||}||| |jj || | |d|j|jdSr) rrrrGrrrr$ hardlink_tor2rrhr)rri link_pathr$s rtest_hardlink_toz1FakePathlibPathFileOperationTest.test_hardlink_tos **,,,NN5)44  ### DGLL33<===IIdnn];;<< yy##d###  ++I66777 **+++ DGLL33<=====rrzreadlink new in Python 3.9cR||ddd}|d}|||||}||||dSNr>r?r@tarJAY)rrrr$r readlink)rrtargetr$s r test_readlinkz.FakePathlibPathFileOperationTest.test_readlinks **,,,NN5%77 )) Iv...yy##  61B1BCCCCCrc|dd}|tj||j||d||jj||tj ||jdS)Nr>r?T)r`) rrrENOENTr$mkdirr2rrryrdir_names r test_mkdirz+FakePathlibPathFileOperationTest.test_mkdirs>>%// ##EL$))H2E2E2KLLL (!!$!///  ++H55666 ##EL$))H2E2E2KLLLLLrc|dd}||||d|jj|d}|||tj ||jddS)Nr>r?Trwr@) rrr$rrrWrrrry)rrris rtest_mkdir_exist_okz4FakePathlibPathFileOperationTest.test_mkdir_exist_oks>>%// !!! (!!4!000GL%%h66  ### ## L$))I..4t $     rcL|dd}||||||jj|||jj|d||dd| t5||ddddn #1swxYwY||jj|ddSNr>r?r@) rrr$rmdirrhrrr2rr7r<rs r test_rmdirz+FakePathlibPathFileOperationTest.test_rmdirs>>%// !!! (!!### ,,X66777  ++DNN5,A,ABBCCC u55666   w ' ' 5 5 IIdnnU++ , , 2 2 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5  ++DNN5,A,ABBCCCCCs ;EEEc R||ddd||ddd||ddd||dd}d|D}|dt ||||ddd|dS)Nr>r?file1file2file3cg|]}|Sr(r(.0entrys r zAFakePathlibPathFileOperationTest.test_iterdir..s666eE666rr)rrr$rrGrassertIn)rr$rs r test_iterdirz-FakePathlibPathFileOperationTest.test_iterdirs ug>>??? ug>>??? ug>>???yyu556666t||~~666 CMM*** diiueW E EFFQQQQQrc ||dd||dd||dd||dd||d}|t |d||dd||ddgdS)Nr>rPz all_tests.py README.mdz setup.pycrrrr$rGsortedglobr:s r test_globz*FakePathlibPathFileOperationTest.test_globs z::;;; ~>>??? {;;<<< {;;<<<yy..//  499V$$ % % $..??@@ $.. ;;<<      rWindows specific testc ||dd||dd||dd||dd||d}|t |d||dd||dd||ddgdSNr>rPz all_tests.PYrz example.Pyrrr:s rtest_glob_case_windowsz7FakePathlibPathFileOperationTest.test_glob_case_windowss< z::;;; ~>>??? {;;<<< |<<===yy..//  499V$$ % % $..??@@ $.. ==>> $.. ;;<<      rzPosix specific testc |||dd||dd||dd||dd||d}|t |d||ddgdSr)rrrr$rGrrr:s rtest_glob_case_posixz5FakePathlibPathFileOperationTest.test_glob_case_posixs  z::;;; ~>>??? {;;<<< |<<===yy..//  499V$$ % % YYt~~eZ88 9 9 :     rN)$r)r*r+rrr>rErmrnr,rrIrNrTrXr]rbrerkrnrqrurzrrrrrrrrrrr.rrr(rrr7r7s?? U U UOOO777 X_ 7"/22 2 SSS...KKKX_S%/1VWW 3 3XW 3JJJ @@@333JJJ999---///   ,+++X_S%.0KLLX_S%02RSS > >TSML >X_S%/1QRR > >SR >X_S%.0LMMDDNMDMMM    D D DRRR    X_^%<==   >=  X_Z!677   87    rr7ceZdZdZdS) RealPathlibPathFileOperationTestcdSrrr(r&s rrz,RealPathlibPathFileOperationTest.use_real_fsrsrNrtr(rrrrrurrc\eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZe j!e"o e#j$dkdd Z%e j!e"o e#j$dkdd!Z&d"Z'd#Z(d$Z)d%Z*d&Z+d'Z,d(Z-e j!e#j$d)kd*d+Z.d,Z/d-Z0e j!e#j1d.kd/d0Z2e j!e#j1d.kd/d1Z3d2Z4d3S)4!FakePathlibUsageInOsFunctionsTestzTest that many os / os.path functions accept a path-like object since Python 3.6. The functionality of these functions is tested elsewhere, we just check that they accept a fake path object as an argument. c d}d}|jj||}|||jj||||||jj||||||jj||||dSNr>r?)rr$rWrG)rdir1dir2dirs r test_joinz+FakePathlibUsageInOsFunctionsTest.test_joinsgld++ dgl// $FFGGG dgl//diiooFFGGG dgl// $4QQRRRRRrc|ddd}||jj||jj||dSNFooBarBaz)rrGrr$normcaserrs r test_normcasez/FakePathlibUsageInOsFunctionsTest.test_normcase sl~~eUE22  GL ! !$ ' ')>)>tyy)O)O     rc|dddd}||jj||jj||dSNr>r?r r@)rrGrr$normpathrs r test_normpathz/FakePathlibUsageInOsFunctionsTest.test_normpathn~~eUD%88  GL ! !$ ' ')>)>tyy)O)O     rc|dddd}||jj||jj||dSr)rrGrr$rrs r test_realpathz/FakePathlibUsageInOsFunctionsTest.test_realpathrrc r|ddd}|ddd}|jj||}|||jj||||||jj||||||jj||||dS)Nr$r!r>r?)rrr$relpathrG)rpath_foopath_barrel_paths r test_relpathz.FakePathlibUsageInOsFunctionsTest.test_relpaths>>&$66>>&$667<''(;; 47<#7#7 (8K8KX#V#VWWW 47<#7#7$))HBUBU#V#VWWW   GL 8!4!4dii6I6I J J     rc|ddd}||jj||jj||dSr)rrGrr$splitrs r test_splitz,FakePathlibUsageInOsFunctionsTest.test_split)sb~~eUE22 ++D1147<3E3EdiiPToo3V3VWWWWWrc|dddd}||jj||jj||dS)NzC:rrr)rrGrr$ splitdrivers rtest_splitdrivez1FakePathlibUsageInOsFunctionsTest.test_splitdrive-so~~dE5%88  GL # #D ) ) GL # #DIIdOO 4 4     rc|dddd}||jj||jj||dSr)rrGrr$abspathrs r test_abspathz.FakePathlibUsageInOsFunctionsTest.test_abspath4n~~eUD%88  GL  & & (<()rr$rWrGr,rs rr/z1FakePathlibUsageInOsFunctionsTest.test_expanduserFsqw|  e,,  GL # #D ) ) GL # #DIIdOO 4 4     rcb||dd}|j|}d|_||jj||jj||dS)Nr>bar1.txt) skip_real_fsrrr _st_mtimerGrr$getmtimerrpath_objs r test_getmtimez/FakePathlibUsageInOsFunctionsTest.test_getmtimeMs ~~eZ00?..t44  GL ! !$ ' ')>)>tyy)O)O     rcb||dd}|j|}d|_||jj||jj||dS)Nr>r*) rrrrst_ctimerGrr$getctimers r test_getctimez/FakePathlibUsageInOsFunctionsTest.test_getctimeV ~~eZ00?..t44  GL ! !$ ' ')>)>tyy)O)O     rcb||dd}|j|}d|_||jj||jj||dS)Nr>r ) rrrrst_atimerGrr$getatimers r test_getatimez/FakePathlibUsageInOsFunctionsTest.test_getatime_rrc(|ddd}||d||jj||jj||dSNr>r?r@1234567r)rrrGrr$getsizer:s r test_getsizez.FakePathlibUsageInOsFunctionsTest.test_getsizehs~~eUE22  222  GL  & & (<(r?r@r)permrr:s rtest_isfile_not_readablez:FakePathlibUsageInOsFunctionsTest.test_isfile_not_readablezs~~eUE22 A&&&  GL   % %tw|':':499T??'K'K     rc$|ddd}||||jj||jj||dSr)rrrGrr$islinkr:s r test_islinkz-FakePathlibUsageInOsFunctionsTest.test_islinkr rc$|ddd}||||jj||jj||dSr)rrrGrr$isdirr:s r test_isdirz,FakePathlibUsageInOsFunctionsTest.test_isdirsv~~eUE22  ++D1147<3E3EdiiPToo3V3VWWWWWrc|jjj}||jj||jj||dSr)rr$rVrGismountr:s r test_ismountz.FakePathlibUsageInOsFunctionsTest.test_ismountscw|  GL  & & (<(|dd}||||dz||j||j||dS)Nr>r?rg)rrrrGrlistdirr$r:s r test_listdirz.FakePathlibUsageInOsFunctionsTest.test_listdirs~~eU++   )*** .. $0P0PQQQQQrc|d}|j||||jj|dS)Nr>)rrrr$r2rr:s rrz,FakePathlibUsageInOsFunctionsTest.test_mkdirs[~~e$$  diioo&&&  ++D1122222rc|dd}|j||||jj|dSr)rrmakedirsr$r2rr:s r test_makedirsz/FakePathlibUsageInOsFunctionsTest.test_makedirss_~~eU++ 4)))  ++D1122222rrzQos.readlink does not to support path-like objects under Windows before Python 3.8c4||ddd}|d}|||||j|||dSrrrrr rrr$rrrs rrz/FakePathlibUsageInOsFunctionsTest.test_readlinks **,,,NN5%77 )) Iv...  0 091E1E F FOOOOOrc4||ddd}|d}|||||j|||dS)NsfoosbarsbazstarJAYr/r0s rtest_readlink_bytesz5FakePathlibUsageInOsFunctionsTest.test_readlink_bytess **,,,NN666::  ** Iv...  0 091E1E F FOOOOOrc|d}|||j||||jj|dS)Ntest.txt)rrrremover$rhrr:s r test_removez-FakePathlibUsageInOsFunctionsTest.test_removesq~~j))  tyy''' ,,T2233333rc*|d}|d}|||j|||||jj||j||||||jj|dSNz test1.txtz test2.txt)rrrrhr$r2rrpath1path2s rrkz-FakePathlibUsageInOsFunctionsTest.test_renames{++{++  tyy''///  ++E22333 tyy''5)9)9:::  ++E2233333rc*|d}|d}|||j|||||jj||j||||||jj|dSr8)rrrr.r$r2rr9s rrnz.FakePathlibUsageInOsFunctionsTest.test_replaces{++{++   %((%000  ++E22333  %(($))E*:*:;;;  ++E2233333rc|dd}|||j||||jj|dSr)rrrrr$rhrr:s rrz,FakePathlibUsageInOsFunctionsTest.test_rmdirsq~~eU++   diioo&&& ,,T2233333rcv|dd}||||jj|dd|j||D}|dt|dS)Nxyzzyplughr4cg|]}|Sr(r(rs rrzBFakePathlibUsageInOsFunctionsTest.test_scandir..sPPPuPPPrrT) rrrrr$rWscandirrGr)r directory dir_entriess r test_scandirz.FakePathlibUsageInOsFunctionsTest.test_scandirsNN7G44   """ **9jAABBBPP$'//$))I:N:N*O*OPPP  C ,,-----rc||d}|d}|||j|||||jj||j||j||||||jj|dS)Nr!r#) rrrrsymlinkr$r2rr5)rrrs r test_symlinkz.FakePathlibUsageInOsFunctionsTest.test_symlinks **,,,NN<00 NN6**  ###  ),,i888  ++I66777 y!!!  ),,dii .B.BCCC  ++I6677777rc|ddd}||d||j|||dSr)rrrGrrr$r:s rrz+FakePathlibUsageInOsFunctionsTest.test_statsp~~eUE22  222 d++TYYt__-A-A-C-CDDDDDrrzNew in Python 3.10c||d}d}||jj||}||jj|d}d}|||||||t|| dtj |t|| dtj dS) Nr>r?r#rrTrF) rrr$rrWrrrGrrST_SIZE)rrC base_namerrrs rtest_stat_follow_symlinksz;FakePathlibUsageInOsFunctionsTest.test_stat_follow_symlinkss$ NN5))  IIdgl// 9EEFF IIdgl// 6BBCC  X666 Iy111  MM9>>$>?? M      NNINN5NAA$,O     rc\|d}||d|j||d|j|}|d|j|d|jdS)Nrrr)rTrU)timesrTrU) rrrutimer$rrGrrrr$sts r test_utimez,FakePathlibUsageInOsFunctionsTest.test_utime%s~~k** ///  diiooV 444 W\\$   BK((( BK(((((rc&|d}||d|j||d|j|}|d|jdS)Nr test_testr)length)rrrtruncater$rrGrrQs r test_truncatez/FakePathlibUsageInOsFunctionsTest.test_truncate-s~~k**  444 4333 W\\$   BJ'''''rr z!no pwd and grp modules in WindowscB|d}||||||||dSNr)rrr2r$ownergroupr:s rtest_owner_and_group_posixz.fake_getpwuid=s.byy(1BCC &/ #""NrcN|dkrtdd}d|_|St)Nr]zgr_name, gr_gidNewGroup)rgr_namerd)re group_structs r fake_getgrgidzUFakePathlibUsageInOsFunctionsTest.test_changed_owner_and_group..fake_getgrgidDs.axx)'3DEE '1 $##Nrrrriz pwd.getpwuidz grp.getgrgidrbrj) rrrrchownrpatchrGr$r\r])rrgrmr$s rtest_changed_owner_and_groupz>FakePathlibUsageInOsFunctionsTest.test_changed_owner_and_group;s       ~~k**   dB""" Z 6 6 F FNM:: F F  DIIdOO,A,A,C,CDDD  TYYt__-B-B-D-DEEE F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F Fs76D' A7D D'D D'D D''D+.D+c||d}|||t5||dddn #1swxYwY|t5||ddddS#1swxYwYdSr[)rrrr7r8r$r\r]r:s rtest_owner_and_group_windowsz>FakePathlibUsageInOsFunctionsTest.test_owner_and_group_windowsTsT !!!~~k**    2 3 3 $ $ IIdOO ! ! # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $   2 3 3 $ $ IIdOO ! ! # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s$(B  BB2(C''C+.C+N)5r)r*r+rrrrrrrrrrrr/rrrrrr r rrrrrrr&r)rr-rmrnr.r,rrr2r6rkrnrrErHrrMrSrYr-r^rprrr(rrrrs SSS            XXX                           XXX         XXX       OOO... 9 9 9RRR 333 333 X_0s'&0 * PP  PX_0s'&0 * PP  P444 444444444 ... 8 8 8EEE X_S%/1EFF  GF )))(((X_S\W,.QRR11SR1 X_S\W,.QRRFFSRF0$$$$$rrceZdZdZdS)!RealPathlibUsageInOsFunctionsTestcdSrrr(r&s rrz-RealPathlibUsageInOsFunctionsTest.use_real_fs_rsrNrtr(rrrtrt^rurrtc2eZdZdZdZdZdZdZdZdS) FakeFilesystemPathLikeObjectTestctjd|_tj|j|_t j|j|_dS)Nr=)path_separator) rFakeFilesystemrrFakePathlibModuler"r FakeOsModulerr&s rrz&FakeFilesystemPathLikeObjectTest.setUpdsC)8LLL#5doFF &t77rcjd}|j|}|j|||jj||tj |j |j tj zdSN foo/bar/baz) r"r#rrr2rr$rrGrrr)rdir_path_stringrs r!test_create_dir_with_pathlib_pathzBFakeFilesystemPathLikeObjectTest.test_create_dir_with_pathlib_pathis'<$$_55 ""8,,,  ++O<<===  L$',,77?$,N     rcjd}|j|}|j|||jj||tj |j |j tj zdSr~) r"r#rrr2rr$rrGrrr)rfile_path_stringrs r"test_create_file_with_pathlib_pathzCFakeFilesystemPathLikeObjectTest.test_create_file_with_pathlib_pathrs(L%%&677  ##I...  ++,<==>>>  L$',,'788@4<O     rc|jd}d}|j|}|j||||jj||tj |j |j tj zdS)Nrzfoo/link) r"r#rrr2rr$rrGrrrr)rrlink_path_stringrs r%test_create_symlink_with_pathlib_pathzFFakeFilesystemPathLikeObjectTest.test_create_symlink_with_pathlib_path{sL%%m44 %L%%&677  &&y)<<<  ,,-=>>???  L GMM* + + 3dl B     rctjt}|j|}|j||tj |jj }| |jj || tj|j |jtjzdSr)rr$r__file__r"r#r add_real_filer.rVr2rrGrrr)rreal_file_path_stringreal_file_pathfake_filepath_strings r-test_add_existing_real_file_with_pathlib_pathzNFakeFilesystemPathLikeObjectTest.test_add_existing_real_file_with_pathlib_paths " 9 9**+@AA %%n5554<>  **=999199"&$'+NN  ++,?@@AAA  L GLL, - - 5 D     rN) r)r*r+rrrrrrr(rrrwrwcsn888                     rrwc\eZdZddZejejdkddZdS)FakeFilesystemChmodTestreturnNc.|dSr)rr&s rrzFakeFilesystemChmodTest.setUps rr rctj|j_t jd}|j||jdd|| |jddd| t5| ddddS#1swxYwYdS)Nz/foo/barrrT)force_unix_mode) r WINDOWSr rr"r#rrr2rr7PermissionErrorr:s r'test_is_file_for_unreadable_dir_windowsz?FakeFilesystemChmodTest.test_is_file_for_unreadable_dir_windowss^ |J'' D!!!  fe$$$  '''  feT :::    / /   LLNNN                  s>C  C$'C$)rN) r)r*r+rrmrnr,r-rr(rrrrs[X_S\W,.EFF  GF   rr__main__rU) verbosity)+rrrr"rr,rm collectionsrrpyfakefsrrrrpyfakefs.fake_filesystemr pyfakefs.helpersr r pyfakefs.tests.test_utilsr r-r.rrr0rprnrwrrrrr4r7rrrtrwrr)mainr(rrrs  """"""UUUUUUUUUUUU++++++--------555555 \W $ 2;_0J9J9J9J9J9$7J9J9J9Z$A Z!<==1A1A1A1A1A-@1A1A>=1Ah-S J J J J J 1J J J Z5 CNCNCNCNCN(;CNCNCNL(I M M M M M ':M M M `'G ^$^$^$^$^$(;^$^$^$B (I 7 7 7 7 7 x'87 7 7 t6?$ zHMAr