§ |<ˆj :ãóê—dZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZejd¦«Zed¦«Zed¦«Zede dfd„¦«Zdedefd„Zdedededefd„Z dede!deeeffd„Z"Gd„d ¦«Z#e#¦«Z$eGd!„d"¦«¦«Z%dS)#z)Monkeypatching and mocking functionality.éN)Úcontextmanager)ÚAny)Ú Generator)ÚList)ÚMapping)ÚMutableMapping)ÚOptional)Úoverload)ÚTuple)ÚTypeVar)ÚUnion)Úfinal)Úfixture)Ú PytestWarningz^No module named (.*)$ÚKÚVÚreturn©Ú MonkeyPatchNNc#óVK—t¦«}|V—| ¦«dS)a A convenient fixture for monkey-patching. The fixture provides these methods to modify objects, dictionaries, or :data:`os.environ`: * :meth:`monkeypatch.setattr(obj, name, value, raising=True) ` * :meth:`monkeypatch.delattr(obj, name, raising=True) ` * :meth:`monkeypatch.setitem(mapping, name, value) ` * :meth:`monkeypatch.delitem(obj, name, raising=True) ` * :meth:`monkeypatch.setenv(name, value, prepend=None) ` * :meth:`monkeypatch.delenv(name, raising=True) ` * :meth:`monkeypatch.syspath_prepend(path) ` * :meth:`monkeypatch.chdir(path) ` * :meth:`monkeypatch.context() ` All modifications will be undone after the requesting test function or fixture has finished. The ``raising`` parameter determines if a :class:`KeyError` or :class:`AttributeError` will be raised if the set/deletion operation does not have the specified target. To undo modifications done by the fixture in a contained scope, use :meth:`context() `. N)rÚundo)Úmpatchs úe/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib/python3.11/site-packages/_pytest/monkeypatch.pyÚ monkeypatchrs+èè€õ2‰]Œ]€FØ €L€L€LØ ‡K‚K�M„M€M€M€MóÚnamecóÆ—| d¦«}| d¦«}t|¦«}|D]¤}|d|zz } t||¦«}Œ#t$rYnwxYw t|¦«nV#t $rI}t |¦« ¦«d}||kr‚t d|›d|›�¦«|‚d}~wwxYwt|||¦«}Œ¥|S)Nú.réÿÿÿÿzimport error in z: )ÚsplitÚpopÚ __import__ÚgetattrÚAttributeErrorÚ ImportErrorÚstrÚannotated_getattr)rÚ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ð øøøð  KÝ �tÑ Ô Ð Ð øÝð Kð Kð Kݘ2‘w”w—}’}‘” rÔ*ˆHؘ4ÒÐØå!Ð"A°TÐ"AÐ"A¸RÐ"AÐ"AÑBÔBÈÐJøøøøð  Køøøõ " %¨¨tÑ4Ô4ˆˆØ €Ls+ÁAÁ A%Á$A%Á)A9Á9 C ÂACÃC ÚobjÚanncó¼— t||¦«}nI#t$r<}td t|¦«j||¦«¦«|‚d}~wwxYw|S)Nz'{!r} object at {} has no attribute {!r})r#r$ÚformatÚtypeÚ__name__)r/rr0Úes rr'r'Wsx€ðÝ�c˜4Ñ Ô ˆˆøÝ ðððÝØ 5× <Ò <Ý�S‘ ” Ô" C¨ñ ô ñ ô ðð  øøøøðøøøð €Js‚“ A�7AÁAÚ import_pathÚraisingcóØ—t|t¦«rd|vrtd|›�¦«‚| dd¦«\}}t |¦«}|rt |||¬¦«||fS)Nrz)must be absolute import path string, not é)r0)Ú isinstancer&Ú TypeErrorÚrsplitr.r')r6r7ÚmoduleÚattrÚtargets rÚderive_importpathr@cs�€Ý �k¥3Ñ 'Ô 'ðU¨3°kÐ+AÐ+AÝÐSÀKÐSÐSÑTÔTÐTØ×%Ò% c¨1Ñ-Ô-�L€FˆDÝ �V‰_Œ_€FØð4ݘ& $¨FÐ3Ñ3Ô3Ð3Ø �ˆ<Ðrcó—eZdZdefd„ZdS)ÚNotsetrcó—dS)Nz©©Úselfs rÚ__repr__zNotset.__repr__ns€ØˆzrN)r4Ú __module__Ú __qualname__r&rGrDrrrBrBms/€€€€€ð˜#ððððððrrBc óò—eZdZdZdd„Zeededfd„¦«¦«Ze dde d e d e d e ddf d „¦«Ze dde d e d e d e ddf d „¦«Zedfdee e fd ee e fd e d e ddf d„Zedfdee e fd ee e fd e ddfd„Zdeeefd ed eddfd„Zddeeefd ed e ddfd„Zd d e d e dee ddfd„Zdd e d e ddfd„Zdd„Zdee dfddfd„Zdd„ZdS)!ra Helper to conveniently monkeypatch attributes/items/environment variables/syspath. Returned by the :fixture:`monkeypatch` fixture. .. versionchanged:: 6.2 Can now also be used directly as `pytest.MonkeyPatch()`, for when the fixture is not available. In this case, use :meth:`with MonkeyPatch.context() as mp: ` or remember to call :meth:`undo` explicitly. rNcó>—g|_g|_d|_d|_dS©N)Ú_setattrÚ_setitemÚ_cwdÚ _savesyspathrEs rÚ__init__zMonkeyPatch.__init__ƒs%€Ø:<ˆŒ ØHJˆŒ Ø#'ˆŒ Ø15ˆÔÐÐrrc#ó‚K—|¦«} |V—| ¦«dS#| ¦«wxYw)a]Context manager that returns a new :class:`MonkeyPatch` object which undoes any patching done inside the ``with`` block upon exit. Example: .. code-block:: python import functools def test_partial(monkeypatch): with monkeypatch.context() as m: m.setattr(functools, "partial", 3) Useful in situations where it is desired to undo some patches before the test ends, such as mocking ``stdlib`` functions that might break pytest itself if mocked (for examples of this see :issue:`3290`). N)r)ÚclsÚms rÚcontextzMonkeyPatch.context‰sDèè€ð* ˆC‰EŒEˆð ؈GˆGˆGà �FŠF‰HŒHˆHˆHˆHøˆA�FŠF‰HŒHˆHˆHøøøsŽ(¨>.r?rÚvaluer7có—dSrLrD©rFr?rrVr7s rÚsetattrzMonkeyPatch.setattr¤ó €ð ˆrcó—dSrLrDrXs rrYzMonkeyPatch.setattr®rZrTcó(—d}ddl}t|t¦«r:t|t¦«st d¦«‚|}t ||¦«\}}n$t|t¦«st d¦«‚t ||t¦«}|r|turt|›d|›�¦«‚|  |¦«r |j   |t¦«}|j   |||f¦«t|||¦«dS)a÷ Set attribute value on target, memorizing the old value. For example: .. code-block:: python import os monkeypatch.setattr(os, "getcwd", lambda: "/") The code above replaces the :func:`os.getcwd` function by a ``lambda`` which always returns ``"/"``. 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: .. code-block:: python monkeypatch.setattr("os.getcwd", lambda: "/") Raises :class:`AttributeError` if the attribute does not exist, unless ``raising`` is set to False. **Where to patch** ``monkeypatch.setattr`` works by (temporarily) changing the object that a name points to with another one. There can be many names pointing to any individual object, so for patching to work you must ensure that you patch the name used by the system under test. See the section :ref:`Where to patch ` in the :mod:`unittest.mock` docs for a complete explanation, which is meant for :func:`unittest.mock.patch` but applies to ``monkeypatch.setattr`` as well. TrNzcuse setattr(target, name, value) or setattr(target, value) with target being a dotted import stringz|use setattr(target, name, value) with name being a string or setattr(target, value) with target being a dotted import stringz has no attribute )Úinspectr:rBr&r;r@r#Únotsetr$ÚisclassÚ__dict__ÚgetrMÚappendrY)rFr?rrVr7Ú__tracebackhide__r]Úoldvals rrYzMonkeyPatch.setattr¸s8€ðT!ÐØˆˆˆå �e�VÑ $Ô $ð ݘf¥cÑ*Ô*ð Ýð$ñôðð ˆEÝ,¨V°WÑ=Ô=‰LˆD�&�&å˜d¥CÑ(Ô(ð Ýð$ñôðõ ˜ ¥vÑ.Ô.ˆØ ð J�v¥Ð'Ð'Ý  FÐ!HÐ!HÀÐ!HÐ!HÑIÔIÐ Ið �?Š?˜6Ñ "Ô "ð 7Ø”_×(Ò(¨­vÑ6Ô6ˆFØ Œ ×Ò˜f d¨FÐ3Ñ4Ô4Ð4Ý�˜˜eÑ$Ô$Ð$Ð$Ð$rcóà—d}ddl}t|t¦«r7t|t¦«st d¦«‚t ||¦«\}}t ||¦«s|rt|¦«‚dSt||t¦«}|  |¦«r |j   |t¦«}|j  |||f¦«t||¦«dS)aKDelete attribute ``name`` from ``target``. 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. Raises AttributeError it the attribute does not exist, unless ``raising`` is set to False. TrNzUuse delattr(target, name) or delattr(target) with target being a dotted import string)r]r:rBr&r;r@Úhasattrr$r#r^r_r`rarMrbÚdelattr)rFr?rr7rcr]rds rrgzMonkeyPatch.delattrs€ð!ÐØˆˆˆå �d�FÑ #Ô #ð >ݘf¥cÑ*Ô*ð Ýð$ñôðõ -¨V°WÑ=Ô=‰LˆD�&å�v˜tÑ$Ô$ð "Øð +Ý$ TÑ*Ô*Ð*ð +ð +õ˜V T­6Ñ2Ô2ˆFà�Š˜vÑ&Ô&ð ;Øœ×,Ò,¨Tµ6Ñ:Ô:�Ø ŒM× Ò  &¨$°Ð!7Ñ 8Ô 8Ð 8Ý �F˜DÑ !Ô !Ð !Ð !Ð !rÚdiccó|—|j ||| |t¦«f¦«|||<dS)z'Set dictionary entry ``name`` to value.N)rNrbrar^)rFrhrrVs rÚsetitemzMonkeyPatch.setitem&s:€à Œ ×Ò˜c 4¨¯ª°µvÑ)>Ô)>Ð?Ñ@Ô@Ð@àˆˆD‰ ˆ ˆ rcó¦—||vr|rt|¦«‚dS|j ||| |t¦«f¦«||=dS)z�Delete ``name`` from dict. Raises ``KeyError`` if it doesn't exist, unless ``raising`` is set to False. N)ÚKeyErrorrNrbrar^)rFrhrr7s rÚdelitemzMonkeyPatch.delitem,sc€ð �sˆ?ˆ?Øð %ݘt‘n”nÐ$ð %ð %ð ŒM× Ò  # t¨S¯WªW°T½6Ñ-BÔ-BÐ!CÑ DÔ DÐ Dà�D� � � rÚprependc óv—t|t¦«sZtjt d ||t |¦«j¬¦«¦«d¬¦«t|¦«}|r&|tj vr||ztj |z}|  tj ||¦«dS)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. zvValue of environment variable {name} type should be str, but got {value!r} (type: {type}); converted to str implicitly)rrVr3é)Ú stacklevelN) r:r&ÚwarningsÚwarnrr2r3r4ÚosÚenvironrj)rFrrVrns rÚsetenvzMonkeyPatch.setenv:sÀõ˜%¥Ñ%Ô%ð Ý ŒMÝðLßLRÊFØ!¨µT¸%±[´[Ô5IðMSñMôMñôð ð ñ ô ð õ˜‘J”JˆEØ ð 7�t�rœzÐ)Ð)ؘG‘O¥b¤j°Ô&6Ñ6ˆEØ � Š •R”Z  uÑ-Ô-Ð-Ð-Ð-rcóN—tj}| |||¬¦«dS)z�Delete ``name`` from the environment. Raises ``KeyError`` if it does not exist, unless ``raising`` is set to False. )r7N)rtrurm)rFrr7rus rÚdelenvzMonkeyPatch.delenvPs)€õ -/¬JˆØ � Š �W˜d¨Gˆ Ñ4Ô4Ð4Ð4Ð4rcó—|j€tjdd…|_tj dt |¦«¦«dtjvrddlm}|t |¦«¦«ddlm }|¦«dS)z:Prepend ``path`` to ``sys.path`` list of import locations.NrÚ pkg_resources)Úfixup_namespace_packages)Úinvalidate_caches) rPÚsysÚpathÚinsertr&Úmodulesrzr{Ú importlibr|)rFr~r{r|s rÚsyspath_prependzMonkeyPatch.syspath_prependYsœ€ð Ô Ð $Ý #¤¨¨¨¤ ˆDÔ Ý Œ�Š˜�3˜t™9œ9Ñ%Ô%Ð%ð �cœkÐ )Ð )Ø >Ð >Ð >Ð >Ð >Ð >à $Ð $¥S¨¡Y¤YÑ /Ô /Ð /ð 0Ð/Ð/Ð/Ð/Ð/àÐÑÔÐÐÐrr~zos.PathLike[str]cól—|j€tj¦«|_tj|¦«dS)zChange the current working directory to the specified path. :param path: The path to change into. N)rOrtÚgetcwdÚchdir)rFr~s rr…zMonkeyPatch.chdirrs*€ð Œ9Ð Ýœ ™ œ ˆDŒIÝ Œ�‰ŒˆˆˆrcóØ—t|j¦«D]1\}}}|turt|||¦«Œ!t ||¦«Œ2g|jdd…<t|j¦«D])\}}}|tur ||=Œ#t $rYŒ wxYw|||<Œ*g|jdd…<|j�|jtj dd…<d|_|j �"tj |j ¦«d|_ dSdS)a³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:: 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. Prefer to use :meth:`context() ` instead. N) ÚreversedrMr^rYrgrNrlrPr}r~rOrtr…)rFr/rrVÚ dictionaryÚkeys rrzMonkeyPatch.undo|s+€õ$!)¨¬Ñ 7Ô 7ð #ð #Ñ ˆC��uØ�FÐ"Ð"ݘ˜T 5Ñ)Ô)Ð)Ð)嘘TÑ"Ô"Ð"Ð"؈Œ �a�a�aÑÝ&.¨t¬}Ñ&=Ô&=ð (ð (Ñ "ˆJ˜˜UØ�ˆˆðà" 3˜˜øÝðððØ�Dðøøøð#(� ˜3‘�؈Œ �a�a�aÑØ Ô Ð (ØÔ+�CŒH�Q�Q�Q‰KØ $ˆDÔ à Œ9Ð Ý ŒH�T”YÑ Ô Ð ØˆDŒIˆIˆIð !Ð sÁ7A;Á; BÂB)rN)..).)TrL)r4rHrIÚ__doc__rQÚ classmethodrrrUr r&ÚobjectrBÚboolrYr^r rgrrrrjrmr rvrxr‚r…rrDrrrrus€€€€€ð ð ð6ð6ð6ð6ð Øð˜ Ð";Ô<ðððñ„^ñ„[ðð2ð Øð  ð àð ðð ðð  ð ð  ð ð  ð ð ñ„Xð ðð ð  ð àð ðð ðð  ð ð  ð ð  ð ð ñ„Xð ðØð F%ðF%à�c˜6�kÔ"ðF%ð�F˜C�KÔ ðF%ðð F%ð ð F%ð ð F%ðF%ðF%ðF%ðV$*Øð $"ð$"à�f˜c�kÔ"ð$"ð�C˜�KÔ ð$"ðð $"ð ð $"ð$"ð$"ð$"ðL˜7 1 a 4œ=ð°ð¸!ðÀððððð ð ˜7 1 a 4œ=ð °ð ¸Dð ÈDð ð ð ð ð.ð.˜3ð. sð.°X¸c´]ð.Èdð.ð.ð.ð.ð,5ð5˜3ð5¨ð5¸ð5ð5ð5ð5ððððð2˜% Ð%7Ð 7Ô8ð¸Tððððð)ð)ð)ð)ð)ð)rr)&rŠrtÚrer}rrÚ contextlibrÚtypingrrrrrr r r r r Ú_pytest.compatrÚ_pytest.fixturesrÚ_pytest.warning_typesrÚcompileÚRE_IMPORT_ERROR_NAMErrrr&rŒr.r'r�r@rBr^rrDrrúr–sˆðØ/Ð/Ø € € € Ø € € € Ø € € € Ø€€€Ø%Ð%Ð%Ð%Ð%Ð%ØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØ!Ð!Ð!Ð!Ð!Ð!ØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐà Ð Ð Ð Ð Ð Ø$Ð$Ð$Ð$Ð$Ð$Ø/Ð/Ð/Ð/Ð/Ð/à!�r”zÐ";Ñ<Ô<Ðð €GˆC�L„L€Ø €GˆC�L„L€ð ð�YÐ8Ô9ðððñ „ðð:�#ð˜&ððððð8 ˜6ð ¨ð °3ð ¸6ð ð ð ð ð 3ð°ð¸%ÀÀVÀ Ô:Lðððððððððñôð𠈉Œ€ððoðoðoðoðoñoôoñ„ðoðoðor