§ x<ˆjZ ã ó¶ — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ej Zd„ Z G d„ dej ¦ « Zed k r ej ¦ « dS dS ) 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 ó: — t j | ||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 ó€ — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z d „ Z ej ed u d¦ « 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 ó — t j t ¦ « | _ t | j d¦ « 5 }| ¦ « | _ ddd¦ « n# 1 swxY w Y | ¦ « 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.setUp7 s© € õ œ×(Ò(Ñ2Ô2ˆŒ Ý �T”] DÑ )Ô )ð *¨QØ!"§¢¡¤ˆDÔð *ð *ð *ñ *ô *ð *ð *ð *ð *ð *ð *øøøð *ð *ð *ð *ð ×ÒÑÔÐÐÐs ¿A%Á%A)Á,A)c ó — d S ©N© ©r s r ÚtearDownzTestExample.tearDownJ s € àˆr c óæ — | t j d¦ « ¦ « t j d¦ « | t j d¦ « ¦ « | t j d¦ « ¦ « t j d¦ « | t j d¦ « ¦ « dS )zSTest example.create_file() which uses `open()` and `file.write()`. ú/testz/test/file.txtN) ÚassertFalser r ÚisdirÚmkdirÚ assertTrueÚexistsr Úcreate_filer! s r Útest_create_filezTestExample.test_create_fileN s² € ð ×Ò�œŸš wÑ/Ô/Ñ0Ô0Ð0Ý Œ�ÑÔÐØ�Š�œŸ š gÑ.Ô.Ñ/Ô/Ð/à×Ò�œŸšÐ(8Ñ9Ô9Ñ:Ô:Ð:ÝÔÐ,Ñ-Ô-Ð-Ø�Š�œŸšÐ'7Ñ8Ô8Ñ9Ô9Ð9Ð9Ð9r c ó. — | j dd¬¦ « | t j d¦ « ¦ « t j d¦ « | t j d¦ « ¦ « dS )z4Test example.delete_file() which uses `os.remove()`.z/test/full.txtzFirst line Second Line )ÚcontentsN) Úfsr* r( r r r) r Údelete_filer% r! s r Útest_delete_filezTestExample.test_delete_fileZ s{ € àŒ×ÒÐ,Ð7RÐÑSÔSÐSØ�Š�œŸšÐ'7Ñ8Ô8Ñ9Ô9Ð9ÝÔÐ,Ñ-Ô-Ð-Ø×Ò�œŸšÐ(8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:r c óÖ — | t j d¦ « ¦ « | j d¦ « | t j d¦ « ¦ « 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_existsa s] € à×Ò�Ô,Ð->Ñ?Ô?Ñ@Ô@Ð@ØŒ×ÒÐ-Ñ.Ô.Ð.Ø�Š�Ô+Ð,=Ñ>Ô>Ñ?Ô?Ð?Ð?Ð?r c óÆ — | t j d¦ « ¦ « | j d¦ « | t j d¦ « ¦ « t j d¦ « | t j d¦ « ¦ « | t j d¦ « g ¦ « t j d¦ « }t t j 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% r r r&