betamaxpy / betamax

A VCR imitation designed only for python-requests.
https://betamax.readthedocs.io/en/latest/
Other
562 stars 61 forks source link

Make _cassette_name a part of API #175

Open jirikuncar opened 4 years ago

jirikuncar commented 4 years ago

Rename _ca(s)sette_name helper function to cassette_name to be a part of the API.

sigmavirus24 commented 4 years ago

Why?

jirikuncar commented 4 years ago

I am using it to define more advanced fixtures. I could try to make the current fixtures more configurable but it will complicate the codebase.

sigmavirus24 commented 4 years ago

I genuinely don't understand your use case. What does "more advanced fixtures" mean?

jirikuncar commented 4 years ago

I have something along this lines in my client tests:

@pytest.fixture(scope="session")
def recorder():
    import betamax
    import client

    session = client.Client("http://localhost:8000")
    with betamax.Betamax(session) as vrc:
        yield vrc

@pytest.fixture
def session(request, recorder):
    from betamax.fixtures.pytest import _casette_name
    recorder.use_cassette(_casette_name(request, True))

    yield recorder.session

and I would like to make sure that _cas(s)ette_name becomes a public API.