ktosiek / pytest-vcr

Py.test integration with VCR.py
MIT License
154 stars 25 forks source link

Pytest-vcr seems not to work #44

Open gustavonmartins opened 3 years ago

gustavonmartins commented 3 years ago

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!

brunetton commented 3 years ago

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

quidproquo commented 3 years ago

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

prescod commented 3 years ago

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