관리-도구
편집 파일: monkeypatch.cpython-311.pyc
� �܋f : � �� � d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlm Z ddlm Z ddlmZ ddlmZ dd lm Z dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlmZ ej d� � Z ed� � Z ed� � Zede d fd�� � Zdedefd�Zdedededefd�Z dede!deeef fd�Z" G d� d � � Z# e#� � Z$e G d!� 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 # �V K � 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) <pytest.MonkeyPatch.setattr>` * :meth:`monkeypatch.delattr(obj, name, raising=True) <pytest.MonkeyPatch.delattr>` * :meth:`monkeypatch.setitem(mapping, name, value) <pytest.MonkeyPatch.setitem>` * :meth:`monkeypatch.delitem(obj, name, raising=True) <pytest.MonkeyPatch.delitem>` * :meth:`monkeypatch.setenv(name, value, prepend=None) <pytest.MonkeyPatch.setenv>` * :meth:`monkeypatch.delenv(name, raising=True) <pytest.MonkeyPatch.delenv>` * :meth:`monkeypatch.syspath_prepend(path) <pytest.MonkeyPatch.syspath_prepend>` * :meth:`monkeypatch.chdir(path) <pytest.MonkeyPatch.chdir>` * :meth:`monkeypatch.context() <pytest.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() <pytest.MonkeyPatch.context>`. N)r �undo)�mpatchs �d/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/_pytest/monkeypatch.py�monkeypatchr s+ � � � �2 �]�]�F� �L�L�L� �K�K�M�M�M�M�M� �namec �� � | � d� � }|� d� � }t |� � }|D ]�}|d|z z } t ||� � }�# t $ r Y nw xY w t |� � nV# t $ rI}t |� � � � � d }||k r� t d|� d|� �� � |�d }~ww xY wt |||� � }��|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<}t d� t | � � j ||� � � � |�d }~ww xY w| S )Nz'{!r} object at {} has no attribute {!r})r# r$ �format�type�__name__)r/ r r0 �es r r'