§
    øÛg!#  ã                   óÐ   — d Z ddlZddlZddlZddlmZ ddlZ ej        d¦  «        Zej	        d„ ¦   «         Z
d„ Zd„ Zd„ Z G d	„ d
¦  «        Z e¦   «         Z G d„ d¦  «        ZdS )z, monkeypatching and mocking functionality.  é    N)Ú_basestringz^No module named (.*)$c                 óV   — t          ¦   «         }|                      |j        ¦  «         |S )aú  The returned ``monkeypatch`` fixture provides these
    helper methods to modify objects, dictionaries or os.environ::

        monkeypatch.setattr(obj, name, value, raising=True)
        monkeypatch.delattr(obj, name, raising=True)
        monkeypatch.setitem(mapping, name, value)
        monkeypatch.delitem(obj, name, raising=True)
        monkeypatch.setenv(name, value, prepend=False)
        monkeypatch.delenv(name, value, raising=True)
        monkeypatch.syspath_prepend(path)
        monkeypatch.chdir(path)

    All modifications will be undone after the requesting
    test function or fixture has finished. The ``raising``
    parameter determines if a KeyError or AttributeError
    will be raised if the set/deletion operation has no target.
    )ÚMonkeyPatchÚaddfinalizerÚundo)ÚrequestÚmpatchs     úI/granary/edev/quantum/lib/python3.11/site-packages/_pytest/monkeypatch.pyÚmonkeypatchr      s(   € õ& ‰]Œ]€FØ×Ò˜œÑ%Ô%Ð%Ø€Mó    c                 óÄ  — |                       d¦  «        }|                     d¦  «        }t          |¦  «        }|D ]£}|d|z   z  }	 t          ||¦  «        }Œ# t          $ r Y nw xY w	 t          |¦  «         nU# t
          $ rH}t          |¦  «                              ¦   «         d         }||k    r‚ t          d|›d|›�¦  «        ‚d }~ww xY wt          |||¦  «        }Œ¤|S )Nú.r   éÿÿÿÿzimport error in z: )ÚsplitÚpopÚ
__import__ÚgetattrÚAttributeErrorÚImportErrorÚstrÚannotated_getattr)ÚnameÚpartsÚusedÚfoundÚpartÚexÚexpecteds          r
   Úresolver   %   s  € à�JŠJ�s‰OŒO€Eà�9Š9�Q‰<Œ<€DÝ�tÑÔ€EØð 5ð 5ˆØ��d‘
Ñˆð	Ý˜E 4Ñ(Ô(ˆEð øõ ð 	ð 	ð 	ØˆDð	øøøð
	Ý�tÑÔÐÐøÝð 	ð 	ð 	å˜2‘w”w—}’}‘” rÔ*ˆHØ˜4ÒÐØå!�kØ04°°°b°bÐ9ñô ð øøøøð	øøøõ " %¨¨tÑ4Ô4ˆˆØ€Ls+   ÁAÁ
A%Á$A%Á)A9Á9
CÂACÃCc                 ó˜   — 	 t          | |¦  «        } n7# t          $ r* t          t          | ¦  «        j        ›d|›d|›�¦  «        ‚w xY w| S )Nz object at ú has no attribute )r   r   ÚtypeÚ__name__)Úobjr   Úanns      r
   r   r   D   sm   € ð
Ý�c˜4Ñ Ô ˆˆøÝð 
ð 
ð 
Ýå˜‘I”IÔ&Ð&Ð&¨¨¨¨T¨Tðñ
ô 
ð 	
ð
øøøð €Js	   ‚ “4Ac                 óØ   — t          | t          ¦  «        rd| vrt          d| ›�¦  «        ‚|                      dd¦  «        \  }}t	          |¦  «        }|rt          |||¬¦  «         ||fS )Nr   z)must be absolute import path string, not é   )r%   )Ú
isinstancer   Ú	TypeErrorÚrsplitr   r   )Úimport_pathÚraisingÚmoduleÚattrÚtargets        r
   Úderive_importpathr0   P   s‡   € Ý�k¥;Ñ/Ô/ð (°3¸kÐ3IÐ3IÝˆiØ$˜ð'ñ (ô (ð 	(à×%Ò% c¨1Ñ-Ô-�L€FˆDÝ�V‰_Œ_€FØð 4Ý˜& $¨FÐ3Ñ3Ô3Ð3Ø�ˆ<Ðr   c                   ó   — e Zd Zd„ ZdS )ÚNotsetc                 ó   — dS )Nz<notset>© ©Úselfs    r
   Ú__repr__zNotset.__repr__\   s   € Øˆzr   N)r#   Ú
__module__Ú__qualname__r7   r4   r   r
   r2   r2   [   s#   € € € € € ðð ð ð ð r   r2   c                   ó`   — e Zd ZdZd„ Zedfd„Zedfd„Zd„ Zdd„Z	dd	„Z
dd
„Zd„ Zd„ Zd„ ZdS )r   zj Object returned by the ``monkeypatch`` fixture keeping a record of setattr/item/env/syspath changes.
    c                 ó>   — g | _         g | _        d | _        d | _        d S ©N)Ú_setattrÚ_setitemÚ_cwdÚ_savesyspathr5   s    r
   Ú__init__zMonkeyPatch.__init__g   s%   € ØˆŒØˆŒØˆŒ	Ø ˆÔÐÐr   Tc                 óÆ  — d}ddl }|t          u r9t          |t          ¦  «        st	          d¦  «        ‚|}t          ||¦  «        \  }}t          ||t          ¦  «        }|r|t          u rt          |›d|›�¦  «        ‚|                     |¦  «        r |j	         
                    |t          ¦  «        }| j                             |||f¦  «         t          |||¦  «         dS )ak   Set attribute value on target, memorizing the old value.
        By default raise AttributeError if the attribute did not exist.

        For convenience you can specify a string as ``target`` which
        will be interpreted as a dotted import path, with the last part
        being the attribute name.  Example:
        ``monkeypatch.setattr("os.getcwd", lambda x: "/")``
        would set the ``getcwd`` function of the ``os`` module.

        The ``raising`` value determines if the setattr should fail
        if the attribute is not already present (defaults to True
        which means it will raise).
        Tr   Nzcuse setattr(target, name, value) or setattr(target, value) with target being a dotted import stringr!   )ÚinspectÚnotsetr(   r   r)   r0   r   r   ÚisclassÚ__dict__Úgetr=   ÚappendÚsetattr)r6   r/   r   Úvaluer,   Ú__tracebackhide__rC   Úoldvals           r
   rI   zMonkeyPatch.setattrm   sþ   € ð !ÐØˆˆˆà•Fˆ?ˆ?Ý˜f¥kÑ2Ô2ð 1Ýð !0ñ 1ô 1ð 1ð ˆEÝ,¨V°WÑ=Ô=‰LˆD�&å˜ ¥vÑ.Ô.ˆØð 	L�v¥Ð'Ð'Ý ¸V¸V¸VÀTÀTÐ!JÑKÔKÐKð �?Š?˜6Ñ"Ô"ð 	7Ø”_×(Ò(¨­vÑ6Ô6ˆFØŒ×Ò˜f d¨FÐ3Ñ4Ô4Ð4Ý�˜˜eÑ$Ô$Ð$Ð$Ð$r   c           	      óR  — d}|t           u r7t          |t          ¦  «        st          d¦  «        ‚t	          ||¦  «        \  }}t          ||¦  «        s|rt          |¦  «        ‚dS | j                             ||t          ||t           ¦  «        f¦  «         t          ||¦  «         dS )a�   Delete attribute ``name`` from ``target``, by default raise
        AttributeError it the attribute did not previously exist.

        If no ``name`` is specified and ``target`` is a string
        it will be interpreted as a dotted import path with the
        last part being the attribute name.

        If ``raising`` is set to False, no exception will be raised if the
        attribute is missing.
        TzUuse delattr(target, name) or delattr(target) with target being a dotted import stringN)rD   r(   r   r)   r0   Úhasattrr   r=   rH   r   Údelattr)r6   r/   r   r,   rK   s        r
   rO   zMonkeyPatch.delattr�   sÄ   € ð !ÐØ•6ˆ>ˆ>Ý˜f¥kÑ2Ô2ð 1Ýð !0ñ 1ô 1ð 1õ -¨V°WÑ=Ô=‰LˆD�&å�v˜tÑ$Ô$ð 	"Øð +Ý$ TÑ*Ô*Ð*ð+ð +ð ŒM× Ò  &¨$µ¸ÀÅfÑ0MÔ0MÐ!NÑOÔOÐOÝ�F˜DÑ!Ô!Ð!Ð!Ð!r   c                 ó|   — | j                              |||                     |t          ¦  «        f¦  «         |||<   dS )z) Set dictionary entry ``name`` to value. N)r>   rH   rG   rD   )r6   Údicr   rJ   s       r
   ÚsetitemzMonkeyPatch.setitemª   s:   € àŒ×Ò˜c 4¨¯ª°µvÑ)>Ô)>Ð?Ñ@Ô@Ð@ØˆˆD‰	ˆ	ˆ	r   c                 ó¦   — ||vr|rt          |¦  «        ‚dS | j                             |||                     |t          ¦  «        f¦  «         ||= dS )z¬ Delete ``name`` from dict. Raise KeyError if it doesn't exist.

        If ``raising`` is set to False, no exception will be raised if the
        key is missing.
        N)ÚKeyErrorr>   rH   rG   rD   )r6   rQ   r   r,   s       r
   ÚdelitemzMonkeyPatch.delitem¯   sc   € ð �sˆ?ˆ?Øð %Ý˜t‘n”nÐ$ð%ð %ð ŒM× Ò  # t¨S¯WªW°T½6Ñ-BÔ-BÐ!CÑDÔDÐDØ�D�	�	�	r   Nc                 ó¶   — t          |¦  «        }|r&|t          j        v r||z   t          j        |         z   }|                      t          j        ||¦  «         dS )zÏ Set environment variable ``name`` to ``value``.  If ``prepend``
        is a character, read the current environment variable value
        and prepend the ``value`` adjoined with the ``prepend`` character.N)r   ÚosÚenvironrR   )r6   r   rJ   Úprepends       r
   ÚsetenvzMonkeyPatch.setenv¼   sV   € õ �E‘
”
ˆØð 	7�t�rœzÐ)Ð)Ø˜G‘O¥b¤j°Ô&6Ñ6ˆEØ�Š•R”Z  uÑ-Ô-Ð-Ð-Ð-r   c                 óJ   — |                       t          j        ||¬¦  «         dS )zÎ Delete ``name`` from the environment. Raise KeyError it does not
        exist.

        If ``raising`` is set to False, no exception will be raised if the
        environment variable is missing.
        )r,   N)rU   rW   rX   )r6   r   r,   s      r
   ÚdelenvzMonkeyPatch.delenvÅ   s$   € ð 	�Š•R”Z ¨wˆÑ7Ô7Ð7Ð7Ð7r   c                 ó    — | j         €t          j        dd…         | _         t          j                             dt	          |¦  «        ¦  «         dS )z< Prepend ``path`` to ``sys.path`` list of import locations. Nr   )r@   ÚsysÚpathÚinsertr   ©r6   r_   s     r
   Úsyspath_prependzMonkeyPatch.syspath_prependÎ   s?   € àÔÐ$Ý #¤¨¨¨¤ˆDÔÝŒ�Š˜�3˜t™9œ9Ñ%Ô%Ð%Ð%Ð%r   c                 ó¸   — | j         €t          j        ¦   «         | _         t          |d¦  «        r|                     ¦   «          dS t          j        |¦  «         dS )z} Change the current working directory to the specified path.
        Path can be a string or a py.path.local object.
        NÚchdir)r?   rW   ÚgetcwdrN   rd   ra   s     r
   rd   zMonkeyPatch.chdirÔ   sM   € ð Œ9ÐÝœ	™œˆDŒIÝ�4˜Ñ!Ô!ð 	Ø�JŠJ‰LŒLˆLˆLˆLåŒH�T‰NŒNˆNˆNˆNr   c                 óØ  — t          | j        ¦  «        D ]1\  }}}|t          urt          |||¦  «         Œ!t	          ||¦  «         Œ2g | j        dd…<   t          | j        ¦  «        D ])\  }}}|t          u r	 ||= Œ# t          $ r Y Œ w xY w|||<   Œ*g | j        dd…<   | j        �| j        t          j	        dd…<   d| _        | j
        �"t          j        | j
        ¦  «         d| _
        dS dS )aE   Undo previous changes.  This call consumes the
        undo stack. Calling it a second time has no effect unless
        you do more monkeypatching after the undo call.

        There is generally no need to call `undo()`, since it is
        called automatically during tear-down.

        Note that the same `monkeypatch` fixture is used across a
        single test function invocation. If `monkeypatch` is used both by
        the test function itself and one of the test fixtures,
        calling `undo()` will undo all of the changes made in
        both functions.
        N)Úreversedr=   rD   rI   rO   r>   rT   r@   r^   r_   r?   rW   rd   )r6   r$   r   rJ   Ú
dictionarys        r
   r   zMonkeyPatch.undoß   s/  € õ !)¨¬Ñ 7Ô 7ð 	#ð 	#ÑˆC��uØ�FÐ"Ð"Ý˜˜T 5Ñ)Ô)Ð)Ð)å˜˜TÑ"Ô"Ð"Ð"ØˆŒ�a�a�aÑÝ'/°´Ñ'>Ô'>ð 	)ð 	)Ñ#ˆJ˜˜eØ�ˆˆðØ" 4Ð(Ð(øÝð ð ð Ø�Dðøøøð $)�
˜4Ñ Ð ØˆŒ�a�a�aÑØÔÐ(ØÔ+�CŒH�Q�Q�Q‰KØ $ˆDÔàŒ9Ð ÝŒH�T”YÑÔÐØˆDŒIˆIˆIð !Ð s   Á7A;Á;
BÂB)Tr<   )r#   r8   r9   Ú__doc__rA   rD   rI   rO   rR   rU   rZ   r\   rb   rd   r   r4   r   r
   r   r   c   sÜ   € € € € € ðð ð!ð !ð !ð +1¸$ð !%ð !%ð !%ð !%ðF $*°4ð "ð "ð "ð "ð4ð ð ð
ð ð ð ð.ð .ð .ð .ð8ð 8ð 8ð 8ð&ð &ð &ð	ð 	ð 	ð#ð #ð #ð #ð #r   r   )ri   rW   r^   ÚreÚ
py.builtinr   ÚpytestÚcompileÚRE_IMPORT_ERROR_NAMEÚfixturer   r   r   r0   r2   rD   r   r4   r   r
   ú<module>rp      s  ðØ 2Ð 2à €€€€€€€Ø 	€	€	€	à "Ð "Ð "Ð "Ð "Ð "à €€€à!�r”zÐ":Ñ;Ô;Ð ð „ðð ñ „ðð.ð ð ð>	ð 	ð 	ðð ð ðð ð ð ð ñ ô ð ð
 
ˆ‰Œ€ð_ð _ð _ð _ð _ñ _ô _ð _ð _ð _r   