File manager - Edit - /opt/cloudlinux/venv/lib/python3.11/site-packages/pyfakefs/tests/__pycache__/example_test.cpython-311.pyc
Back
� �|oiZ � � � 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.10/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&