%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/monkey.cpython-312.pyc |
� Ϫ�f� � � � G d � d� Z y)c �@ � e Zd ZdZd� Zd� Zd� Zd� ZeZd� Z d d�Z d � Zy)� MonkeyPatcherzn Cover up attributes with new objects. Neat for monkey-patching things for unit-testing purposes. c �L � g | _ g | _ |D ] } | j |� � y �N)�_patchesToApply� _originals�addPatch)�self�patches�patchs �7/usr/lib/python3/dist-packages/twisted/python/monkey.py�__init__zMonkeyPatcher.__init__ s0 � �!��� ���� "�E��D�M�M�5�!� "� c �@ � | j j |||f� y)z� Add a patch so that the attribute C{name} on C{obj} will be assigned to C{value} when C{patch} is called or during C{runWithPatches}. You can restore the original values with a call to restore(). N)r �append�r �obj�name�values r r zMonkeyPatcher.addPatch s � � ���#�#�S�$��$6�7r c �D � | j D ] \ }}}||f||fk( s� y y)zc Has the C{name} attribute of C{obj} already been patched by this patcher? TF)r )r r r �o�n�vs r �_alreadyPatchedzMonkeyPatcher._alreadyPatched s5 � � ��� �G�A�q�!��1�v�#�t��$�� � r c � � | j D ]M \ }}}| j ||� s(| j j ||t ||� f� t |||� �O y)z� Apply all of the patches that have been specified with L{addPatch}. Reverse this operation using L{restore}. N)r r r r �getattr�setattrr s r r zMonkeyPatcher.patch) s\ � � !%� 4� 4� &��C��u��'�'��T�2����&�&��T�7�3��3E�'F�G��C��u�%� &r c � � | j r9| j j � \ }}}t |||� | j r�8yy)zE Restore all original values to any patched objects. N)r �popr r s r �restorezMonkeyPatcher.restore5 s9 � � �o�o�#���2�2�4��C��u��C��u�%� �o�or Nc �$ � | j � y r )r )r �excType�excValue�excTracebacks r �__exit__zMonkeyPatcher.__exit__= s � ����r c �~ � | j � ||i |��| j � S # | j � w xY w)z� Apply each patch already specified. Then run the function f with the given args and kwargs. Restore everything when done. )r r )r �f�args�kws r �runWithPatcheszMonkeyPatcher.runWithPatches@ s0 � � � � �� ��d�>�b�>��L�L�N��D�L�L�N�s �* �<)NNN)�__name__� __module__�__qualname__�__doc__r r r r � __enter__r r$ r) � r r r r s1 � �� "�8��&� �I�&�� r r N)r r/ r r �<module>r0 s ��B� Br