Your IP : 216.73.216.213


Current Path : /opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyo

�
��\c@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZddl
mZddlmZmZddlZ
ddlmZmZddlmZd	e	fd
��YZdej	fd��YZd
efd��YZdefd��YZdefd��YZddlZdefd��YZdefd��YZ dej	fd��YZ!de"fd��YZ#dej	fd��YZ$defd��YZ%dej	fd ��YZ&d!efd"��YZ'd#ej	fd$��YZ(d%ej	fd&��YZ)d'ej	ej*fd(��YZ+d)ej	fd*��YZ,e-d+kr�ej.�ndS(,sL
Test the :py:class`pyfakefs.fake_filesystem_unittest.TestCase` base class.
i����N(tTestCase(tfake_filesystem_unittesttfake_filesystem(tpathlib(tPatchertPause(tIS_PYPYtIS_PY2(tmodule_with_attributestTestPatchercBseZd�ZRS(c	Cs]t��N}|jjddd�td��}|j�}WdQX|jd|�WdQXdS(Ns/foo/bartcontentsttest(Rtfstcreate_filetopentreadtassertEqual(tselftpatchertfR
((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_context_manager's
(t__name__t
__module__R(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR	&stTestPyfakefsUnittestBasecBseZd�ZRS(cCs|j�dS(sSet up the fake file systemN(t
setUpPyfakefs(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pytsetUp0s(RRR(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR/stTestPyfakefsUnittestcBseZdZejejddkd�d��Zd�Zd�Z	d�Z
d�Zd	�Zeje
d
�d��ZRS(sATest the `pyfakefs.fake_filesystem_unittest.TestCase` base class.iisfile() was removed in Python 3cCs�|jtjjd��tdd��}|jd�WdQX|j|jjd��td��}|j�}WdQX|j	|d�dS(sFake `file()` function is bounds/fake_file.txttws6This test file was created using the file() function.
N(
tassertFalsetostpathtexiststfiletwritet
assertTrueRRR(RRtcontent((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt	test_file8scCs�|jtjjd��tdd��}|jd�WdQX|j|jjd��td��}|j�}WdQX|j	|d�dS(sFake `open()` function is bounds/fake_file.txtRs6This test file was created using the open() function.
N(
RRRRRR!R"RRR(RRR#((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt	test_openEscCs�|jtjjd��tjdd��}|jd�WdQX|j|jjd��td��}|j	�}WdQX|j
|d�dS(sFake io module is bounds/fake_file.txtRs9This test file was created using the io.open() function.
N(RRRRtioRR!R"RRR(RRR#((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_io_openPscCsC|j|jjd��tjd�|j|jjd��dS(sFake os module is bounds/test/dir1/dir2N(RRRRtmakedirsR"(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_os\s
cCs�tjjd�}|jtjd�g�|jjd�tjd�}|rf|j|dg�n|j|dg�|jjd�ttjd��}|r�|j|ddg�n|j|ddg�dS(sFake glob module is boundtwins/test/dir1/dir*s/test/dir1/dir2as\test\dir1\dir2as/test/dir1/dir2bs\test\dir1\dir2bN(tsystplatformt
startswithRtglobRt
create_dirtsorted(Rt
is_windowstmatching_paths((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt	test_globbs		cCs||jjd�|jjd�|j|jjd��|j|jjd��tjd�|j|jjd��dS(sFake shutil module is bounds/test/dir1/dir2as/test/dir1/dir2bs
/test/dir1N(RR/R"RtshutiltrmtreeR(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_shutilvs
s only run if pathlib is availablec
Cs�tjd��,}|jd��}|jd�WdQXWdQXtjjd�}|rq|j|jj	d��n|j|jj	d��dS(Ns/fake_file.txtRttextR*s\fake_file.txt(
RtPathRR!R+R,R-R"RR(RtpRR1((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_fakepathlib�s(RRt__doc__tunittesttskipIfR+tversion_infoR$R%R'R)R3R6RR:(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR5s					
tTestPatchingImportscBszeZd�Zd�Zer*d�Znd�Zd�Zd�Zd�Z	e
jeo]e
d�d��Zd	�ZRS(
cCsOd}|jj|�|j|jj|��|jtjjj|��dS(Ns/foo/bar/baz(RR
R"Rtpyfakefstteststimport_as_exampletcheck_if_exists1(Rt	file_path((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_import_as_other_name�s
cCsOd}|jj|�|j|jj|��|jtjjj|��dS(s/Make sure `from os import path` patches `path`.s/foo/bar/bazN(RR
R"RR@RARBtcheck_if_exists2(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_import_path_from_os�s
cCs6d}|jj|�|jtjjj|��dS(Ns/foo/bar(RR/R"R@RARBtcheck_if_exists3(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_import_path_from_pathlib�scCs6d}|jj|�|jtjjj|��dS(Ns/foo/bar(RR/R"R@RARBtcheck_if_exists5(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt!test_import_function_from_os_path�scCs6d}|jj|�|jtjjj|��dS(Ns/foo/bar(RR/R"R@RARBtcheck_if_exists6(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt/test_import_function_from_os_path_as_other_name�scCsHd}|jj|dd�tjjj|�}|jd|j�dS(Ns/foo/barR
tabci(RR
R@RARBt
file_stat1Rtst_size(RRDtstat_result((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_import_function_from_os�scCsHd}|jj|dd�tjjj|�}|jd|j�dS(Ns/foo/barR
RNi(RR
R@RARBt
file_stat2RRP(RRDRQ((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt*test_import_function_from_os_as_other_name�ss3Not working for PyPy2 as it is implemented via filecCsEd}|jj|dd�tjjj|�}|jd|�dS(Ns/foo/barR
RN(RR
R@RARBtfile_contents1R(RRDR
((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_import_open_as_other_name�scCsEd}|jj|dd�tjjj|�}|jd|�dS(Ns/foo/barR
RN(RR
R@RARBtfile_contents2R(RRDR
((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt!test_import_io_open_as_other_name�s(RRRERGRRIRKRMRRRTR<R=RRRVRX(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR?�s						t!TestAttributesWithFakeModuleNamescBseZdZd�ZRS(sXTest that module attributes with names like `path` or `io` are not
    stubbed out.
    cCsc|jtjd�|jtjd�|jtjd�|jtjd�|jtjd�dS(s/Attributes of module under test are not patchedsos attribute valuespath attribute valuespathlib attribute valuesshutil attribute valuesio attribute valueN(RRRRRR4R&(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_attributes�s(RRR;RZ(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRY�stTestPathNotPatchedIfNotOsPathcBseZdZd�ZRS(s�Tests that `path` is not patched if it is not `os.path`.
       An own path module (in this case an alias to math) can be imported
       and used.
    cCs|jdtjd��dS(Nig@(RRtfloor(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_own_path_module�s(RRR;R](((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR[�stFailedPatchingTestcBs2eZdZejd��Zejd��ZRS(s�Negative tests: make sure the tests for `modules_to_reload` and
    `modules_to_patch` fail if not providing the arguments.
    cCsBd}|jj|dd�|jdtjjj|�j�dS(Ns/foo/barR
Ri(RR
RR@RARBtsystem_statRP(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_system_stat�scCs6d}|jj|�|jtjjj|��dS(Ns/foo/bar(RR/R"R@RARBtcheck_if_exists4(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_path_exists�s(RRR;R<texpectedFailureR`Rb(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR^�stReloadModuleTestcBs eZdZd�Zd�ZRS(s`Make sure that reloading a module allows patching of classes not
    patched automatically.
    cCs|jdtjjg�dS(sSet up the fake file systemtmodules_to_reloadN(RR@RARB(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRs	cCs6d}|jj|�|jtjjj|��dS(Ns/foo/bar(RR/R"R@RARBRa(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRbs(RRR;RRb(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRd�s	tFakeExampleModulecBs5eZdZejjZd�Zd�Zd�Z	RS(sfUsed to patch a function that uses system-specific functions that
    cannot be patched automatically.cCsdS(N((RR((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt__init__scCs
tj|�S(N(Rtstat(Rtfilepath((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR_scCst|j|�S(s4Forwards any non-faked calls to the standard module.(tgetattrt_orig_module(Rtname((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt__getattr__s(
RRR;R@RARBRkRgR_Rm(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRfs
		tPatchModuleTestcBs eZdZd�Zd�ZRS(s`Make sure that reloading a module allows patching of classes not
    patched automatically.
    cCs|jditd6�dS(sSet up the fake file systemtmodules_to_patchs pyfakefs.tests.import_as_exampleN(RRf(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR!s	cCsBd}|jj|dd�|jdtjjj|�j�dS(Ns/foo/barR
Ri(RR
RR@RARBR_RP(RRD((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR`(s(RRR;RR`(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRns	tPauseResumeTestcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCstj�}|j|jj|j��|jtjj|j��|j�|j|jj|j��|j	tjj|j��tj�}|j	|jj|j��|jtjj|j��|j
�|j	tjj|j��|jtjj|j��dS(N(ttempfiletNamedTemporaryFileR"RRRlRRtpauseRtresume(Rtfake_temp_filetreal_temp_file((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_pause_resume0s

cCs�tj�}|j|jj|j��|jtjj|j��|jj�|jtjj|j��|jj	�|j|jj|j��|j
tjj|j��tj�}|j
|jj|j��|jtjj|j��|jj	�|j
|jj|j��|jtjj|j��|jj�|j
tjj|j��|jtjj|j��dS(N(RqRrR"RRRlRRRtRsR(RRuRv((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_pause_resume_fs>s"



cCstj�}|j|jj|j��|jtjj|j��t|���|j|jj|j��|j	tjj|j��tj�}|j	|jj|j��|jtjj|j��WdQX|j	tjj|j��|jtjj|j��dS(N(
RqRrR"RRRlRRRR(RRuRv((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt test_pause_resume_contextmanagerSs
"cCstj�}|j|jj|j��|jtjj|j��t|j���|j|jj|j��|j	tjj|j��tj�}|j	|jj|j��|jtjj|j��WdQX|j	tjj|j��|jtjj|j��dS(N(
RqRrR"RRRlRRRR(RRuRv((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt#test_pause_resume_fs_contextmanager`s"cCs#tj�}|jt|j�dS(N(RtFakeFilesystemtassertRaisestRuntimeErrorRt(RR((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt!test_pause_resume_without_patcherms(RRRwRxRyRzR~(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRp/s
			
	
tPauseResumePatcherTestcBseZd�Zd�ZRS(cCs"t��}tj�}|j|jj|j��|jtjj|j��|j	�|j|jj|j��|j
tjj|j��tj�}|j
|jj|j��|jtjj|j��|j�|j
tjj|j��|jtjj|j��WdQXdS(N(RRqRrR"RRRlRRRsRRt(RR9RuRv((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRwss

cCs!t��}tj�}|j|jj|j��|jtjj|j��t	|���|j|jj|j��|j
tjj|j��tj�}|j
|jj|j��|jtjj|j��WdQX|j
tjj|j��|jtjj|j��WdQXdS(N(RRqRrR"RRRlRRRR(RR9RuRv((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRy�s
"(RRRwRy(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRrs	tTestCopyOrAddRealFilecBskeZdZd	Zed��Zeje	j
dkd�d��Zd�Zd�Z
d�Zd�ZRS(
s�Tests the `fake_filesystem_unittest.TestCase.copyRealFile()` method.
    Note that `copyRealFile()` is deprecated in favor of
    `FakeFilesystem.add_real_file()`.
    cCs�t}|jd�r"|d }ntjj|�|_t|j��}|j�|_WdQXt|jd��}|j�|_	WdQXtj
|j�|_dS(Ns.pyci����trb(t__file__tendswithRRtabspathRiRRtreal_string_contentstreal_byte_contentsRht	real_stat(tclstfilenameR((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt
setUpClass�s
tdarwinsDifferent copy behaviorcCsH|j|j�}|jd|jkd�|jd|jkd�|j|j|j�|jt|j�t|j	j��|j|j
|j	j
�|j|j|j	jdd�|j|j
|j	j
dd�|j|j
|j	j
d�|j|j|j	jdd�|j|j|j	j�|j|j|j	j�dS(s*Typical usage of deprecated copyRealFile()s5class TestCopyOrAddRealFile(TestPyfakefsUnittestBase)s Verify real file string contentssVerify real file byte contentstplacesii
N(tcopyRealFileRiR"R�R�Rt
byte_contentstocttst_modeR�RPtassertAlmostEqualtst_ctimetst_atimet
assertLesstst_mtimetst_uidtst_gid(Rt	fake_file((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_copy_real_file�s*		%c	Cs�|j|jj|j��|j|j|j�|j|jj|j��|jt��|j|jd�WdQX|jt��|j|jdt�WdQXdS(s#Deprecated copyRealFile() argumentss/different/filenameNtcreate_missing_dirs(	RRRRiR�R"R|t
ValueErrortFalse(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt(test_copy_real_file_deprecated_arguments�scCs[|jj|j�}|j|jj|j��|j|j�|j|j|j	�dS(s<Add a real file to the fake file system to be read on demandN(
Rt
add_real_fileRiR"RtassertIsNonet_byte_contentsRR�R�(RR�((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_add_real_file�scCsztjjtjj|j��d}|jj|�|j|jj|��|j|jjtjj	|d���dS(saAdd a real directory and the contained files to the fake file system
        to be read on demandisfake_filesystem.pyN(
RRtsplittdirnameRiRtadd_real_directoryR"Rtjoin(Rt
real_dir_path((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_add_real_directory�s
	%cCs�tjjtjj|j��d}|jj|tj�|j|jj	|��|j|jj	tjj
|d���dS(s2Add a real directory ending with a path separator.isfake_filesystem.pyN(RRR�R�RiRR�tsepR"RR�(RR�((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt&test_add_real_directory_with_backslash�s
%N(RRR;tNoneRitclassmethodR�R<R=R+R,R�R�R�R�R�(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR��s$	
		tTestPyfakefsTestCasecBseZd�Zd�ZRS(cCs,dtjfd��Y}|d�|_dS(NtTestTestCasecBseZd�ZRS(cSsdS(N((R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pytrunTest�s(RRR�(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR��sR�(RRt	test_case(RR�((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR�scCs0|j|jtj�|j|jtj�dS(N(tassertIsInstanceR�R<RRt
TestCaseMixin(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_test_case_type�s(RRRR�(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR��s	tTestTempFileReloadcBs eZdZd�Zd�ZRS(sbRegression test for #356 to make sure that reloading the tempfile
    does not affect other tests.cCs,t��}|jjddd�WdQXdS(Ns/mytempfileR
tabcd(RRR
(RR((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_fakefsscCs)tjdd�}|j|jd�dS(NtIi(tmultiprocessingtValueRtvalue(Rtv((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt
test_value
s(RRR;R�R�(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR�s	tTestPyfakefsTestCaseMixincBseZd�ZRS(cCs:|j�|jt|d��|j|jtj�dS(NR(RR"thasattrR�RRR{(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_set_up_pyfakefss
(RRR�(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR�stTestShutilWithZipfilecBs)eZdZd�Zd�Zd�ZRS(sRegression test for #427.cCs|j�|jjd�dS(Nsfoo/bar(RRR
(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyRs
cCstjdddd�dS(Ntarchivetziptroot_dirtfoo(R4tmake_archive(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_ascCstjdddd�dS(NR�R�R�R�(R4R�(R((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyttest_b"s(RRR;RR�R�(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyR�s		t__main__(/R;R.R&RR�R4R+RqR<RR@RRtpyfakefs.extra_packagesRt!pyfakefs.fake_filesystem_unittestRRt pyfakefs.tests.import_as_exampletpyfakefs.helpersRRtpyfakefs.tests.fixturesRR	RRR?RYtmathRR[R^RdtobjectRfRnRpRR�R�R�R�R�R�Rtmain(((s]/opt/alt/python27/lib/python2.7/site-packages/pyfakefs/tests/fake_filesystem_unittest_test.pyt<module>sH	W>
Cb