Your IP : 216.73.216.249


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

B

xG�Z��@s�dZddlmZddlZddlZddlZddlZddlmZ	dd�Z
dd	�Zddd�Zej
d
d��Zej
dd��Zej
dd��Zej
dd��ZdS)zYA set of fixtures to integrate Betamax with py.test.

.. autofunction:: betamax_session

�)�absolute_importN�)�recordercCst�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�	_sanitizesrcCs~d}|jdk	r||jjd7}|jdk	r8||jjd7}|rN|t|jj�7}n,||jj7}|jj|jjkrztjdt	dd�|S)aDetermine 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_names


rTcCs@t||d�}t��}t�|�}|�|�|��|�|j�|S)N)r)	r�requestsZSession�betamaxZBetamaxZuse_cassette�startZaddfinalizer�stop)rrr�sessionrr	r	r
�_betamax_recorder=s

r!cCs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!)rr	r	r
�betamax_recorderGsr"cCs|jS)aGenerate a session that has Betamax already installed.

    See `betamax_recorder` fixture.

    :param betamax_recorder:
        A recorder fixture with a configured request session.
    :returns:
        An instantiated requests Session wrapped by Betamax.
    )r )r"r	r	r
�betamax_session^sr#cCst�dt�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 with parameters if parametrized.
    For example, if your test is in ``test_stuff.py`` and
    the method is ``TestStuffClass.test_stuff`` with parameter ``True`` then
    your cassette name will be
    ``test_stuff_TestStuffClass_test_stuff[True]``.

    :param request:
        A request object from pytest giving us context information for the
        fixture.
    :returns:
        An instantiated recorder.
    z�betamax_parametrized_recorder and betamax_parametrized_session will be removed in betamax 1.0. Their behavior will be the default.T)r)rr�DeprecationWarningr!)rr	r	r
�betamax_parametrized_recordermsr%cCs|jS)a!Generate a session that has Betamax already installed.

    See `betamax_parametrized_recorder` fixture.

    :param betamax_parametrized_recorder:
        A recorder fixture with a configured request session.
    :returns:
        An instantiated requests Session wrapped by Betamax.
    )r )r%r	r	r
�betamax_parametrized_session�sr&)T)�__doc__�
__future__rrrZpytestrrrrrrr!Zfixturer"r#r%r&r	r	r	r
�<module>s#