4(&$B"dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddl m Z m Z mZddlmZmZmZGddZGd d Zdd ZGddejZdZGddZGddeeZdS)z;Common helper classes used in tests, or as test class base.N)contextmanager)mock)fake_filesystem fake_openfake_os)is_byte_string to_stringis_rootceZdZdZdZdZdS) DummyTimezBMock replacement for time.time. Increases returned time on access.c"||_||_dSN current_time increment)self curr_timers k/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pyfakefs/tests/test_utils.py__init__zDummyTime.__init__$s%"c>|j}|xj|jz c_|Srr)rargskwargsrs r__call__zDummyTime.__call__(s&(  T^+rN)__name__ __module__ __qualname____doc__rrrrr r !s8LL###rr c&eZdZdZdZdZdZdS) DummyMockcdSrrrs rstartzDummyMock.start/ rcdSrrr#s rstopzDummyMock.stop2r%rc|Srrr#s r __enter__zDummyMock.__enter__5s rcdSrr)rexc_typeexc_valexc_tbs r__exit__zDummyMock.__exit__8r%rN)rrrr$r'r)r.rrrr!r!.sP           rr!cHtjdt||S)Nzpyfakefs.helpers.now)rpatchr )r$steps r time_mockr4<s :,it.D.D E EErcpeZdZdZejdkZejdkZejdkZdZ e dZ dS)TestCasezz-RealFsTestMixin.make_path.."s///3 #///r)rFrGtupler\r[rijoinr )rrrirs r make_pathzRealFsTestMixin.make_paths d1ge} - - >DAw ? ?w|((y~~>>K//$/// tw| 7$7777rc|sdS|}g}|r|jj|s|jj|\}}|s<|r:|jj|s|j|n7|d||r|jj||D]W}|jj||}|j||j |dX|r:|j d}||z}|j ||j ||dS)zCreate the directory at `dir_path`, including subdirectories. `dir_path` shall be composed using `make_path()`. Nrr) r[riexistssplitrYadd_mount_pointinsertrmkdirchmodumask)rdir_pathperm apply_umask existing_path components componentrs r create_dirzRealFsTestMixin.create_dir%s  F   ,DGL$7$7 $F$F ,'+w|'9'9-'H'H $M9  w|**=99CO33MBBB   a + + + ,DGL$7$7 $F$F ,$ 0 0I GL--mYGGM GMM- ( ( ( GMM- / / / /  !GMM%((E UFND GMM%   h%%%%%rNc ||jj||t |rdnd}d|i}||||}|dkrd|d<|j|fi|5}|||dddn #1swxYwY|r:|jd} || z}|j| |j ||dS)zCreate the given file at `file_path` with optional contents, including subdirectories. `file_path` shall be composed using `make_path()`. Nwbwmodeutf8encodingr) rr[rirjrencoderZwriterr) r file_pathcontentsrrrrrfrs r create_filezRealFsTestMixin.create_file?sW  ,,Y77888+~h/G/G+ttS$  H$8x00H 3;;!'F:  TYy + +F + + "q#!!! " " " " " " " " " " " " " " "  !GMM%((E UFND GMM%   i&&&&&s>B""B&)B&c||jj||j||dS)zCreate the path at `link_path`, and a symlink to this path at `target_path`. `link_path` shall be composed using `make_path()`. N)rr[rirjsymlink)r link_path target_paths rcreate_symlinkzRealFsTestMixin.create_symlinkWsD  ,,Y77888  Y/////rct|rdnd}d|i}|dkrd|d<|j|fi|5}|||ddddS#1swxYwYdS)zcCompare `contents` with the contents of the file at `file_path`. Asserts equality. rbrrrrN)rrZr;read)rrrrrrs rcheck_contentszRealFsTestMixin.check_contents^s&h//8ttS$ 3;;!'F:  TYy + +F + + 1q   Xqvvxx 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s)A''A+.A+c|j|j}|jjdz|_|jjrd|jz|_||jkrs||j|j|js|j|j||dSdSdSdS)z1Create the path used as base path in `make_path`.NbasepathzC:)rYr\rrpresetrrr~)r old_base_paths rrtzRealFsTestMixin.create_basepathis ? & NM!_;jHDN, 7!%!6.. ,O))+++--dn==?O..t~>>> ,((***** ' & /. -,rc|jrt|dd}t|dd}tjdkrR|r>|||||dS|||dS|jrZ|t|ddt|dddS|||dS)Nz\\?\ntz /private/var/z/var/) rOstrreplacer[namerbr;path_with_short_usernamerQ)rr?r>s rassert_equal_pathsz"RealFsTestMixin.assert_equal_pathsxs= ? /[[((B77F8}},,Y;;Hw$4#3#3#5#5  11&9911(;;   22222 ] /   F ##OW==H %%ow??        VX . . . . .rc|tj}t|dkr(|ddddz|d<tj|S)Nz~1)rr[rlenupperr)rirs rrz(RealFsTestMixin.path_with_short_usernamesaZZ'' z??a  &qM"1"-3355rs"BA  %%%%%%8888888888??????????                 FFFF55555x 555,PPPE5E5E5E5E5E5E5E5P %(%(%(%(%(X%(%(%(%(%(r