Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/_pytest/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/_pytest/__pycache__/tmpdir.cpython-37.pyc

B

C$�X�@spdZddlZddlZddlZddlmZGdd�d�Zdd�ZeZdd	�Z	ej
d
d�dd
��Zej
dd��ZdS)zA support for providing temporary directories to test functions.  �N)�MonkeyPatchc@s<eZdZdZdd�Zddd�Zddd	�Zd
d�Zdd
�ZdS)�TempdirFactoryz�Factory for temporary directories under the common base temp directory.

    The base directory can be configured using the ``--basetemp`` option.
    cCs||_|j�d�|_dS)N�tmpdir)�config�trace�get)�selfr�r	�?/opt/alt/python37/lib/python3.7/site-packages/_pytest/tmpdir.py�__init__szTempdirFactory.__init__�cCs|��j||d�S)a* (deprecated) return temporary directory path with
            the given string as the trailing part.  It is usually
            better to use the 'tmpdir' function argument which
            provides an empty unique-per-test-invocation directory
            and is guaranteed to be empty.
        )�dir)�getbasetemp�ensure)r�stringr
r	r	r
�
ensuretempszTempdirFactory.ensuretempTcCs>|��}|s|�|�}ntjjj|d|dd�}|�d|�|S)z�Create a subdirectory of the base temporary directory and return it.
        If ``numbered``, ensure the directory is unique by adding a number
        prefix greater than any existing one.
        rN)�prefixZkeep�rootdirZlock_timeout�mktemp)r�mkdir�py�path�local�make_numbered_dirr)r�basename�numbered�basetemp�pr	r	r
rs
zTempdirFactory.mktempcCs�y|jStk
r�|jjj}|rJtj�|�}|��r@|�	�|�
�nHtjj��}t�}|rp|�
d|�}n|}|jdd�tjjjd|d�}|��|_}|�d|�|SXdS)z" return base temporary directory. zpytest-of-%sr)r
zpytest-)rrznew basetempN)Z	_basetemp�AttributeErrorr�optionrrrr�check�removerZget_temproot�get_user�joinrr�realpathr)rrZtemproot�userr�tr	r	r
r+s(


zTempdirFactory.getbasetempcCs|�d�dS)N�finish)r)rr	r	r
r'FszTempdirFactory.finishN)r)T)	�__name__�
__module__�__qualname__�__doc__rrrrr'r	r	r	r
r	s


rc	Cs.ddl}y|��Sttfk
r(dSXdS)zqReturn the current user name, or None if getuser() does not work
    in the current environment (see #1010).
    rN)�getpassZgetuser�ImportError�KeyError)r,r	r	r
r"Js
r"cCsLt�}t|�}|j�|j|jg�|j|d|dd�|jtd|jdd�dS)aCreate a TempdirFactory and attach it to the config object.

    This is to comply with existing plugins which expect the handler to be
    available at pytest_configure time, but ideally should be moved entirely
    to the tmpdir_factory session fixture.
    �_tmpdirhandlerF)ZraisingrN)	rr�_cleanup�extendZundor'�setattr�pytestr)rZmpr&r	r	r
�pytest_configureYs
r4Zsession)ZscopecCs|jjS)z;Return a TempdirFactory instance for the test session.
    )rr/)�requestr	r	r
�tmpdir_factorygsr6cCsD|jj}t�dd|�}d}t|�|kr2|d|�}|j|dd�}|S)z�Return a temporary directory path object
    which is unique to each test function invocation,
    created as a sub directory of the base temporary
    directory.  The returned object is a `py.path.local`_
    path object.
    z[\W]�_�NT)r)�node�name�re�sub�lenr)r5r6r:ZMAXVAL�xr	r	r
rnsr)
r+r;r3rZ_pytest.monkeypatchrrr"ZTempdirHandlerr4Zfixturer6rr	r	r	r
�<module>sA