§ x<ˆjZãó¶—dZddlZddlZddlZddlZddlmZddlmZddl m Z ej Z d„Z Gd„dej¦«Zed krej¦«dSdS) aV Test the :py:class`pyfakefs.example` module to demonstrate the usage of the :py:class`pyfakefs.fake_filesystem_unittest.TestCase` base class. Fake filesystem functions like `create_file()`, `create_dir()` or `create_symlink()` are often used to set up file structures at the beginning of a test. While you could also use the familiar `open()`, `os.mkdirs()` and similar functions, these functions can make the test code shorter and more readable. `create_file()` is particularly convenient because it creates all parent directories and allows you to specify the contents or the size of the file. éN)Úfake_filesystem_unittest)Úscandir)Úexamplecó:—tj|||t¦«S)z9Load the pyfakefs/example.py doctest tests into unittest.)rÚ load_doctestsr)ÚloaderÚtestsÚignores úm/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib/python3.11/site-packages/pyfakefs/tests/example_test.pyÚ load_testsr +s€å #Ô 1°&¸%ÀÍÑ QÔ QÐQócó€—eZdZdZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z e j ed ud ¦«d „¦«Zd „Zd S)Ú TestExamplezÐTest the example module. The os and shutil modules have been replaced with the fake modules, so that all of the calls to os and shutil in the tested example code occur in the fake filesystem. có —tj t¦«|_t |jd¦«5}| ¦«|_ddd¦«n #1swxYwY| ¦«dS)aÃInvoke the :py:class:`pyfakefs.fake_filesystem_unittest.TestCase` `self.setUp()` method. This defines: * Attribute `self.fs`, an instance of :py:class:`pyfakefs.fake_filesystem.FakeFilesystem`. This is useful for creating test files. * Attribute `self.stubs`, an instance of :py:class:`pyfakefs.mox3_stubout.StubOutForTesting`. Use this if you need to define additional stubs. ÚrbN) ÚosÚpathÚrealpathÚ__file__ÚfilepathÚio_openÚreadÚ real_contentsÚ setUpPyfakefs)ÚselfÚfs r ÚsetUpzTestExample.setUp7s©€õœ×(Ò(­Ñ2Ô2ˆŒ Ý �T”] DÑ )Ô )ð *¨QØ!"§¢¡¤ˆDÔ ð *ð *ð *ñ *ô *ð *ð *ð *ð *ð *ð *øøøð *ð *ð *ð *ð ×ÒÑÔÐÐÐs¿A%Á%A)Á,A)có—dS©N©©rs r ÚtearDownzTestExample.tearDownJs€à ˆr cóæ—| tj d¦«¦«tjd¦«| tj d¦«¦«| tj d¦«¦«tjd¦«| tj d¦«¦«dS)zSTest example.create_file() which uses `open()` and `file.write()`. ú/testz/test/file.txtN) Ú assertFalserrÚisdirÚmkdirÚ assertTrueÚexistsrÚ create_filer!s r Útest_create_filezTestExample.test_create_fileNs²€ð ×Ò�œŸš wÑ/Ô/Ñ0Ô0Ð0Ý Œ�ÑÔÐØ �Š�œŸ š  gÑ.Ô.Ñ/Ô/Ð/à ×Ò�œŸšÐ(8Ñ9Ô9Ñ:Ô:Ð:ÝÔÐ,Ñ-Ô-Ð-Ø �Š�œŸšÐ'7Ñ8Ô8Ñ9Ô9Ð9Ð9Ð9r có.—|j dd¬¦«| tj d¦«¦«t jd¦«| tj d¦«¦«dS)z4Test example.delete_file() which uses `os.remove()`.z/test/full.txtzFirst line Second Line )ÚcontentsN) Úfsr*r(rrr)rÚ delete_filer%r!s r Útest_delete_filezTestExample.test_delete_fileZs{€à Œ×ÒÐ,Ð7RÐÑSÔSÐSØ �Š�œŸšÐ'7Ñ8Ô8Ñ9Ô9Ð9ÝÔÐ,Ñ-Ô-Ð-Ø ×Ò�œŸšÐ(8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:r cóÖ—| tjd¦«¦«|j d¦«| tjd¦«¦«dS)z9Test example.path_exists() which uses `os.path.exists()`.z/test/empty.txtN)r%rÚ path_existsr.r*r(r!s r Útest_file_existszTestExample.test_file_existsas]€à ×Ò�Ô,Ð->Ñ?Ô?Ñ@Ô@Ð@Ø Œ×ÒÐ-Ñ.Ô.Ð.Ø �Š�Ô+Ð,=Ñ>Ô>Ñ?Ô?Ð?Ð?Ð?r cóÆ—| tj d¦«¦«|j d¦«| tj d¦«¦«tjd¦«| tj d¦«¦«| tj d¦«g¦«tj   d¦«}ttj d¦«¦«}|r| |ddg¦«d S| |ddg¦«d S) zTest example.get_glob().r$ú/test/dir1/dir2aú/test/dir1/dir2bz/test/dir1/nonexistent*Úwinz/test/dir1/dir*z/test/dir1\dir2az/test/dir1\dir2bN)r%rrr&r.Ú create_dirr(ÚmakedirsÚ assertEqualrÚget_globÚsysÚplatformÚ startswithÚsorted)rÚ is_windowsÚmatching_pathss r Útest_get_globszTestExample.test_get_globsgs-€à ×Ò�œŸš wÑ/Ô/Ñ0Ô0Ð0Ø Œ×ÒÐ-Ñ.Ô.Ð.Ø �Š�œŸ š Ð&8Ñ9Ô9Ñ:Ô:Ð:å Œ Ð&Ñ'Ô'Ð'Ø �Š�œŸ š Ð&8Ñ9Ô9Ñ:Ô:Ð:à ×Ò�Ô)Ð*CÑDÔDÀbÑIÔIÐIÝ”\×,Ò,¨UÑ3Ô3ˆ Ý¥Ô 0Ð1BÑ CÔ CÑDÔDˆØ ð WØ × Ò ˜^Ð.AÐCVÐ-WÑ XÔ XÐ XÐ XÐ Xà × Ò ˜^Ð.@ÐBTÐ-UÑ VÔ VÐ VÐ VÐ Vr có¶—|j d¦«tjd¦«| tj d¦«¦«| tj d¦«¦«tjd¦«|  tj  d¦«¦«dS)z/Test example.rm_tree() using `shutil.rmtree()`.r5r6z /test/dir1N) r.r8rr9r(rr&rÚrm_treer%r)r!s r Ú test_rm_treezTestExample.test_rm_treexs¤€à Œ×ÒÐ-Ñ.Ô.Ð.å Œ Ð&Ñ'Ô'Ð'Ø �Š�œŸ š Ð&8Ñ9Ô9Ñ:Ô:Ð:Ø �Š�œŸ š Ð&8Ñ9Ô9Ñ:Ô:Ð:匘 Ñ%Ô%Ð%Ø ×Ò�œŸš¨ Ñ5Ô5Ñ6Ô6Ð6Ð6Ð6r có¶—|j d¦«|j d¦«|j d¦«|j dd¦«t t jd¦«d„¬¦«}| dt|¦«¦«| d |d j ¦«|  |d   ¦«¦«|  |d   ¦«¦«|  |d   ¦«¦«d S)zÞTest example.scandir() which uses `os.scandir()`. The os module has been replaced with the fake os module so the fake filesystem path entries are returned instead of `os.DirEntry` objects. ú/test/text.txtú /test/dirz/linktest/linkedz/test/linked_filer$có—|jSr©Úname©Úes r úz-TestExample.test_os_scandir..�ó€À!Ä&€r ©ÚkeyéÚ linked_fileéréN)r.r*r8Úcreate_symlinkr?rÚscan_dirr:ÚlenrKr(Úis_dirÚ is_symlinkÚis_file©rÚentriess r Útest_os_scandirzTestExample.test_os_scandirƒs'€ð Œ×ÒÐ,Ñ-Ô-Ð-Ø Œ×Ò˜;Ñ'Ô'Ð'Ø Œ×ÒÐ.Ñ/Ô/Ð/Ø Œ×ÒÐ2Ð4FÑGÔGÐGå�Ô)¨'Ñ2Ô2Ð8HÐ8HÐIÑIÔIˆØ ×Ò˜�C ™LœLÑ)Ô)Ð)Ø ×Ò˜¨°¬ ¬Ñ8Ô8Ð8Ø �Š˜ œ ×)Ò)Ñ+Ô+Ñ,Ô,Ð,Ø �Š˜ œ ×-Ò-Ñ/Ô/Ñ0Ô0Ð0Ø �Š˜ œ ×*Ò*Ñ,Ô,Ñ-Ô-Ð-Ð-Ð-r Nz+Testing only if scandir module is installedcóò—|j d¦«|j d¦«tt jd¦«d„¬¦«}| dt|¦«¦«| d|dj¦«|  |d   ¦«¦«|  |d  ¦«¦«d S) zòTest example.scandir() which uses `scandir.scandir()`. The scandir module has been replaced with the fake_scandir module so the fake filesystem path entries are returned instead of `scandir.DirEntry` objects. rGrHr$có—|jSrrJrLs r rNz2TestExample.test_scandir_scandir..¡rOr rPrUztext.txtrTrN) r.r*r8r?rrWr:rXrKr(rYr[r\s r Útest_scandir_scandirz TestExample.test_scandir_scandir–sÔ€ð Œ×ÒÐ,Ñ-Ô-Ð-Ø Œ×Ò˜;Ñ'Ô'Ð'å�Ô)¨'Ñ2Ô2Ð8HÐ8HÐIÑIÔIˆØ ×Ò˜�C ™LœLÑ)Ô)Ð)Ø ×Ò˜ W¨Q¤Z¤_Ñ5Ô5Ð5Ø �Š˜ œ ×)Ò)Ñ+Ô+Ñ,Ô,Ð,Ø �Š˜ œ ×*Ò*Ñ,Ô,Ñ-Ô-Ð-Ð-Ð-r có>—| t¦«5tj|j¦«ddd¦«n #1swxYwY|j |j¦«| tj|j¦«|j¦«dS)z_Test `example.file_contents()` for a real file after adding it using `add_real_file()`.N) Ú assertRaisesÚOSErrorrÚ file_contentsrr.Ú add_real_filer:rr!s r Útest_real_file_accessz!TestExample.test_real_file_access§sÄ€ð× Ò �wÑ 'Ô 'ð 1ð 1Ý Ô ! $¤-Ñ 0Ô 0Ð 0ð 1ð 1ð 1ñ 1ô 1ð 1ð 1ð 1ð 1ð 1ð 1øøøð 1ð 1ð 1ð 1à Œ×Ò˜dœmÑ,Ô,Ð,Ø ×Ò�Ô.¨t¬}Ñ=Ô=¸tÔ?QÑRÔRÐRÐRÐRs›AÁAÁA)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr"r+r0r3rBrEr^ÚunittestÚskipIfrrargr r r rr0sà€€€€€ððð ððð& ð ð ð :ð :ð :ð;ð;ð;ð@ð@ð@ð WðWðWð" 7ð 7ð 7ð.ð.ð.ð&€X„_�W �_Ð&SÑTÔTð.ð.ñUÔTð.ð SðSðSðSðSr rÚ__main__)rkÚiorr<rlÚpyfakefsrÚpyfakefs.legacy_packagesrÚpyfakefs.testsrÚopenrr ÚTestCaserrhÚmainr r r úrvsëðð ð ð € € € Ø € € € Ø € € € Ø€€€à-Ð-Ð-Ð-Ð-Ð-Ø,Ð,Ð,Ð,Ð,Ð,Ø"Ð"Ð"Ð"Ð"Ð"ð Œ'€ðRðRðRð }Sð}Sð}Sð}Sð}SÐ*Ô3ñ}Sô}Sð}Sð@ ˆzÒÐØ€H„M�O„O€O€O€OðÐr