
    \d                           G d  d          Z dS )c                   B    e Zd ZdZd Zd Zd Zd ZeZd Z	d
dZ
d	 ZdS )MonkeyPatcherzn
    Cover up attributes with new objects. Neat for monkey-patching things for
    unit-testing purposes.
    c                 @    g | _         g | _        |D ]} | j        |  d S N)_patchesToApply
_originalsaddPatch)selfpatchespatchs      5lib/python3.11/site-packages/twisted/python/monkey.py__init__zMonkeyPatcher.__init__   s>    !  	" 	"EDM5!!!	" 	"    c                 @    | j                             |||f           dS )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   zMonkeyPatcher.addPatch   s(     	##S$$677777r   c                 <    | j         D ]\  }}}||f||fk    r dS dS )zc
        Has the C{name} attribute of C{obj} already been patched by this
        patcher?
        TF)r   )r	   r   r   onvs         r   _alreadyPatchedzMonkeyPatcher._alreadyPatched   s?    
  	 	GAq!1v#t$$tt %ur   c           	          | j         D ]X\  }}}|                     ||          s+| j                            ||t	          ||          f           t          |||           YdS )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   zMonkeyPatcher.patch)   s|    
 !% 4 	& 	&Cu''T22 H&&T733E3E'FGGGCu%%%%	& 	&r   c                     | j         r7| j                                         \  }}}t          |||           | j         5dS dS )zE
        Restore all original values to any patched objects.
        N)r   popr   r   s       r   restorezMonkeyPatcher.restore5   sZ     o 	&#2244CuCu%%% o 	& 	& 	& 	& 	&r   Nc                 .    |                                   d S r   )r   )r	   excTypeexcValueexcTracebacks       r   __exit__zMonkeyPatcher.__exit__=   s    r   c                     |                                   	  ||i ||                                  S # |                                  w xY 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   runWithPatcheszMonkeyPatcher.runWithPatches@   sF    
 	

	1d>b>>LLNNNNDLLNNNNs	   2 A)NNN)__name__
__module____qualname____doc__r   r   r   r   	__enter__r   r$   r)    r   r   r   r      s         
" " "8 8 8  & & & I& & &   	 	 	 	 	r   r   N)r   r/   r   r   <module>r0      sA   B B B B B B B B B Br   