Your IP : 216.73.216.249
B
xG�Z� � @ s� d Z ddlmZ ddlZddlZddlZddlZddlmZ dd� Z
dd � Zddd�Zej
d
d� �Zej
dd� �Zej
dd� �Zej
dd� �ZdS )zYA set of fixtures to integrate Betamax with py.test.
.. autofunction:: betamax_session
� )�absolute_importN� )�recorderc C s t �dd| �S )z�
Replace certain characters (which might be problematic when contained in
strings which will be used as file names) by '-'s. z[\s/<>:\\"|?*]�-)�re�sub)�name� r �H/opt/alt/python37/lib/python3.7/site-packages/betamax/fixtures/pytest.py� _sanitize s r c C s~ d}| j dk r|| j jd 7 }| jdk r8|| jjd 7 }|rN|t| jj�7 }n,|| jj7 }| jj| jjkrztjdt dd� |S )a Determine a cassette name from request.
:param request:
A request object from pytest giving us context information for the
fixture.
:param parametrized:
Whether the name should consider parametrized tests.
:returns:
A cassette name.
� N�.z�betamax_recorder and betamax_session currently don't include parameters in the cassette name. Use betamax_parametrized_recorder/_session to include parameters. This behavior will be the default in betamax 1.0� )�
stacklevel)
�module�__name__�clsr �noder �function�warnings�warn�
FutureWarning)�request�parametrized�
cassette_namer r r
�
_casette_name s
r Tc C s@ t | |d�}t�� }t�|�}|�|� |�� | �|j� |S )N)r ) r �requestsZSession�betamaxZBetamaxZuse_cassette�startZaddfinalizer�stop)r r r �sessionr r r r
�_betamax_recorder= s
r! c C s t | dd�S )a� Generate a recorder with a session that has Betamax already installed.
This will create a new Betamax instance with a generated cassette name.
The cassette name is generated by first using the module name from where
the test is collected, then the class name (if it exists), and then the
test function name. For example, if your test is in ``test_stuff.py`` and
is the method ``TestStuffClass.test_stuff`` then your cassette name will be
``test_stuff_TestStuffClass_test_stuff``. If the test is parametrized,
the parameters will not be included in the name. In case you need that,
use betamax_parametrized_recorder instead. This will change in 1.0.0,
where parameters will be included by default.
:param request:
A request object from pytest giving us context information for the
fixture.
:returns:
An instantiated recorder.
F)r )r! )r r r r
�betamax_recorderG s r"