bgAdZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddl m Z m Z mZddlmZmZGddZGd d Zdd ZGddejZGddZGddeeZdS)z;Common helper classes used in tests, or as test class base.N)contextmanager)mock)fake_filesystem fake_openfake_os)is_byte_string to_stringceZdZdZdZdZdS) DummyTimezBMock replacement for time.time. Increases returned time on access.c"||_||_dSN current_time increment)self curr_timers j/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyfakefs/tests/test_utils.py__init__zDummyTime.__init__#s%"c>|j}|xj|jz c_|Sr r)rargskwargsrs r__call__zDummyTime.__call__'s&(  T^+rN)__name__ __module__ __qualname____doc__rrrrr r s8LL###rr c&eZdZdZdZdZdZdS) DummyMockcdSr rrs rstartzDummyMock.start. rcdSr rr"s rstopzDummyMock.stop1r$rc|Sr rr"s r __enter__zDummyMock.__enter__4s rcdSr r)rexc_typeexc_valexc_tbs r__exit__zDummyMock.__exit__7r$rN)rrrr#r&r(r-rrrr r -sP           rr cHtjdt||S)Nzpyfakefs.helpers.now)rpatchr )r#steps r time_mockr3;s :,it.D.D E EErcteZdZdZejdkZejdkZejdkZdZ dZ e dZ dS)TestCasezz-RealFsTestMixin.make_path..1s///3 #///r)rErFtuplerXrWrejoinr )rrrers rrzRealFsTestMixin.make_path%s d1ge} - - >DAw ? ?w|((y~~>>K//$/// tw| 7$7777rcp|sdS|}g}|r|jj|s|jj|\}}|s<|r:|jj|s|j|n7|d||r|jj||D]W}|jj||}|j||j |dX|j ||dS)zCreate the directory at `dir_path`, including subdirectories. `dir_path` shall be composed using `make_path()`. Nrr) rWreexistssplitrUadd_mount_pointinsertrmkdirchmod)rdir_pathperm existing_path components components r create_dirzRealFsTestMixin.create_dir4sG  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- / / / /  h%%%%%rNc||jj||t |rdnd}||||}|||5}|||dddn #1swxYwY|j||dS)zCreate the given file at `file_path` with optional contents, including subdirectories. `file_path` shall be composed using `make_path()`. Nwbw) rrWrerfrencoderVwriter)r file_pathcontentsencodingrmodefs r create_filezRealFsTestMixin.create_fileJs  ,,Y77888+~h/G/G+ttS  H$8x00H YYy$ ' ' "1#!!! " " " " " " " " " " " " " " "  i&&&&&s7BB"Bc||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)rrWrerfr)rr target_paths rcreate_symlinkzRealFsTestMixin.create_symlinkYsD  ,,Y77888  Y/////rct|rdnd}|||5}|||ddddS#1swxYwYdS)zcCompare `contents` with the contents of the file at `file_path`. Asserts equality. rbrN)rrVr:read)rrrrrs rcheck_contentszRealFsTestMixin.check_contents`s&h//8ttS YYy$ ' ' 11   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:)rUrXr~rlresetrrrz)r old_base_paths rrpzRealFsTestMixin.create_basepathhs ? & 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/) rNstrreplacerWnamer^r:path_with_short_usernamerP)rr>r=s rassert_equal_pathsz"RealFsTestMixin.assert_equal_pathsws= ? /[[((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)rrWr}lenupperr)rers rrz(RealFsTestMixin.path_with_short_usernamesaZZ'' z??a  &qM"1"-3355rs"BA  %%%%%%888888888866666666                 FFFF55555x 555.K5K5K5K5K5K5K5K5\ %(%(%(%(%(X%(%(%(%(%(r