Your IP : 216.73.216.196
B
C$�X# � @ s� d Z ddlZddlZddlZddlmZ ddlZe�d�Zej dd� �Z
dd� Zd d
� Zdd� Z
G d
d� d�Ze� ZG dd� d�ZdS )z, monkeypatching and mocking functionality. � N)�_basestringz^No module named (.*)$c c s t � } | V | �� dS )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.
N)�MonkeyPatch�undo)Zmpatch� r �D/opt/alt/python37/lib/python3.7/site-packages/_pytest/monkeypatch.py�monkeypatch
s r c C s� | � d�}|�d�}t|�}x�|D ]�}|d| 7 }yt||�}W q" tk
rT Y nX q"yt|� W nN tk
r� } z0t|�� � d }||kr�� ntd||f ��W d d }~X Y nX t|||�}q"W |S )N�.r ���zimport error in %s: %s)�split�pop�
__import__�getattr�AttributeError�ImportError�str�annotated_getattr)�name�parts�used�found�part�exZexpectedr r r �resolve% s(
r c C s@ yt | |�} W n, tk
r: tdt| �j||f ��Y nX | S )Nz#%r object at %s has no attribute %r)r
r �type�__name__)�objr �annr r r r D s r c C sR t | t�rd| kr td| f ��| �dd�\}}t|�}|rJt|||d� ||fS )Nr z+must be absolute import path string, not %r� )r )�
isinstancer � TypeError�rsplitr r )Zimport_path�raising�module�attr�targetr r r �derive_importpathP s
r% c @ s e Zd Zdd� ZdS )�Notsetc C s dS )Nz<notset>r )�selfr r r �__repr__\ s zNotset.__repr__N)r �
__module__�__qualname__r( r r r r r&