Edit File: mox3_stubout.cpython-311.pyc
� ����n�d�����������������������,�����d�Z�ddlZ�G�d��d������������ZdS�)a��� This is a fork of the pymox library intended to work with Python 3. The file was modified by quermit@gmail.com and dawid.fatyga@gmail.com Previously, pyfakefs used just this file from the mox3 library. However, mox3 will soon be decommissioned, yet standard mock cannot be used because of the problem described in pyfakefs #182 and mock issue 250 (https://github.com/testing-cabal/mock/issues/250). Therefore just this file was forked from mox3 and incorporated into pyfakefs. �����Nc��������������������6�����e�Zd�ZdZd��Zd��Zd��Zd��Zd��Zd��Z dS�) �StubOutForTestinga���Sample Usage: You want os.path.exists() to always return true during testing. stubs = StubOutForTesting() stubs.Set(os.path, 'exists', lambda x: 1) ... stubs.UnsetAll() The above changes os.path.exists into a lambda that returns 1. Once the ... part of the code finishes, the UnsetAll() looks up the old value of os.path.exists and restores it. c������������������"�����g�|�_���������g�|�_��������d�S��N)�cache�stubs��selfs��� �f/builddir/build/BUILD/cloudlinux-venv-1.0.2/venv/lib/python3.11/site-packages/pyfakefs/mox3_stubout.py�__init__zStubOutForTesting.__init__.���s�������� ��� � � �����c������������������V�����|��������������������������������������|�������������������������������������d�S�r���)�smart_unset_all� unset_allr ���s��� r����__del__zStubOutForTesting.__del__2���s*�������������������r ���c����������������������t����������j��������|������������st����������j��������|������������s||j��������v�r|}t ����������||������������}n�t����������j��������|������������s't����������t����������j��������|j��������������������������������}n!t����������t����������j��������|������������������������}|������������������������������������d}|D�]%} �|}t ����������||������������}�#�t����������$�r�Y��"w�xY�w|�t����������d�������������|j��������� ��������������������|������������}|�$t����������|t����������������������rt����������|������������}|�j �����������������������������|||f�������������t����������|||�������������dS�)a���Replace obj.attr_name with new_attr. This method is smart and works at the module, class, and instance level while preserving proper inheritance. It will not stub out C types however unless that has been explicitly allowed by the type. This method supports the case where attr_name is a staticmethod or a classmethod of obj. Notes: - If obj is an instance, then it is its class that will actually be stubbed. Note that the method Set() does not do that: if obj is an instance, it (and not its class) will be stubbed. - The stubbing is using the builtin getattr and setattr. So, the __get__ and __set__ will be called when stubbing (TODO: A better idea would probably be to manipulate obj.__dict__ instead of getattr() and setattr()). Raises AttributeError if the attribute cannot be found. NzAttribute not found.)�inspect�ismodule�isclass�__dict__�getattr�list�getmro� __class__�reverse�AttributeError�get� isinstance�staticmethodr����append�setattr) r ����obj� attr_name�new_attr�orig_obj� orig_attr�mro�cls� old_attributes ��� r���� smart_setzStubOutForTesting.smart_set6���ss�����*���C� � �� ����$�$� �)2�c�l�)B�)B��H���Y�/�/�I�I���?�3�'�'�� 0��7�>�#�-�8�8�9�9����7�>�#�.�.�/�/���K�K�M�M�M��I��� �� ���"�H� '��Y� 7� 7�I�I��%��������H�������� �!7�8�8�8����(�(��3�3� ��$��M�<�)P�)P�$�$�Y�/�/�I�� ���8�Y� �:�;�;�;���)�X�.�.�.�.�.s����<C� C�Cc������������������l�����|�j���������������������������������������������|�j���������D�]}t����������|����g�|�_���������dS�)z�Reverses all the SmartSet() calls. Restores things to their original definition. Its okay to call SmartUnsetAll() repeatedly, as later calls have no effect if no SmartSet() calls have been made. N)r���r���r!���)r ����argss��� r���r���z!StubOutForTesting.smart_unset_alln���s?������� � �������J�� �� �D��T�N�N�N��� � � r ���c������������������V����t����������||������������}|j�����������������������������|������������}|�Nt����������|t����������������������rt ����������|������������}n)t����������|t ����������������������rt����������|j��������������������}|�j�����������������������������|||f�������������t����������|||�������������dS�)a��Replace child_name's old definition with new_child. Replace definition in the context of the given parent. The parent could be a module when the child is a function at module scope. Or the parent could be a class when a class' method is being replaced. The named child is set to new_child, while the prior definition is saved away for later, when unset_all() is called. This method supports the case where child_name is a staticmethod or a classmethod of parent. N) r���r���r���r���r����classmethod�__func__r���r ���r!���)r ����parent� child_name� new_child� old_childr)���s��� r����setzStubOutForTesting.set|���s���������F�J�/�/� ���+�+�J�7�7� ��$��-��6�6�� <�(��3�3� � ��M�;�7�7�� <�'� �(:�;�;� �� ���6�9�j�9�:�:�:��� �I�.�.�.�.�.r ���c�����������������������|�j���������������������������������������������|�j���������D�]\��}}}t����������|||��������������g�|�_���������dS�)z�Reverses all the Set() calls. Restores things to their original definition. Its okay to call unset_all() repeatedly, as later calls have no effect if no Set() calls have been made. N)r���r���r!���)r ���r0���r3���r1���s��� r���r���zStubOutForTesting.unset_all����sP������� � ������-1�Z�� 3�� 3�)�F�I�z��F�J� �2�2�2�2��� � � r ���N) �__name__� __module__�__qualname__�__doc__r���r���r*���r���r4���r�����r ���r���r���r������sy�������������� �� �����������6/��6/��6/�p�����/��/��/�0��������r ���r���)r9���r���r���r:���r ���r����<module>r;������sV����� �� ������D��D��D��D��D��D��D��D��D��Dr ���