pytest-vcr icon indicating copy to clipboard operation
pytest-vcr copied to clipboard

Pytest-vcr seems not to work

Open gustavonmartins opened this issue 3 years ago • 3 comments

I was using python-vcr before, which was working as expected, but I need it to be active only for testing purposes. On production I need contact to the real API.

Hi, I used pytest-vcr, version 1.0.1 and 1.0.2 and it didnt generate any cassete file.

My code is as follows:

@pytest.mark.vcr()
def _get_json_from_api(
    prog: str, iref: str, cpno: str, ipai: int
):
    import requests

    ADDRESS= config("ADDRESS", cast=str)

    payload = {
        "prog": prog,
        "iref": iref,
        "ipai": str(ipai),
        "cpno": cpno,
    }
    request = requests.get(
        ADDRESS,
        params=payload,
        verify=False,
    )
    return request.json()

I didnt see any cassete being generated, and no warning whatsoever came. Im quite lost.

Can you give me a hint on how to solve this?

Thank you so much!

gustavonmartins avatar Mar 04 '21 11:03 gustavonmartins

Are you sure you installed pytest-vcr package ? (pip install pytest-vcr)

brunetton avatar Mar 31 '21 11:03 brunetton

Having same issue. Does this not work with requests package?

quidproquo avatar Jun 01 '21 13:06 quidproquo

The thing you marked is not a test. You can only mark tests.

prescod avatar Aug 01 '21 10:08 prescod