Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Disable Recording from Fixture #116

Open
Wyko opened this issue Jul 6, 2023 · 1 comment
Open

[FEATURE] Disable Recording from Fixture #116

Wyko opened this issue Jul 6, 2023 · 1 comment

Comments

@Wyko
Copy link

Wyko commented Jul 6, 2023

Is your feature request related to a problem? Please describe.
I need to be able to turn on and off vcr via a fixture. Currently I have a fixture that changes the fqdn of the test calls based on the environment. I want to run vcr on certain calls, but not others. I can change the record_mode based on the fixture by including it in vcr_config, but disabling it via none causes it to raise errors, which I don't want.

Describe the solution you'd like
Some fixture that I can use to disable vcr entirely. Maybe an update to vcr_config that adds a key which pytest-recording inspects before passing it on to vcr, like:

@pytest.fixture(scope="module", autouse=True)
def vcr_config(enable_vcr : bool):
    return {
        "filter_post_data_parameters": [("password", "TEST_REPLACED_PASSWORD")],
        "record_mode": "once",
        "pytest-recording": {
            "enable": enable_vcr,
        },
    }
@mezhaka
Copy link

mezhaka commented Jul 26, 2023

I am interested in this feature as well (I was hoping that not recording the fixture is the default behavior). I am testing a REST client, which does some authentication steps that I would rather not record.

@pytest.fixture
def client():
    c = MyClient()
    c.login()
    yield c

@pytest.mark.vcr
def test_client_frobnicates(client)
    f = client.frobnicate("foobar")
    assert f == "yay"

If you could tell me if there is a way to use pytest-recording for such use case, I'd be happy. My current idea is to fall back to vcr context manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants