betamaxpy / betamax

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

expose a betamax_recorder pytest fixture that returns the recorder. #93

Closed davidovich closed 8 years ago

davidovich commented 8 years ago

This is useful in cases where you would like to customize the recorder in a dependent fixture.

The api is not broken by this change, the betamax_session fixture now just returns betamax_recorder.session.

For an example use-case, this allows evaluating current cassette state to start a dependent server if no cassettes are present (for seeding operations):

@pytest.fixture
def  ensure_server():
    # start heavy server
    ...

@pytest.fixture
def cassette_session(request, betamax_recorder, ensure_server):
    # start server if cassette is empty
    if betamax_recorder.current_cassette.is_empty():
        ensure_server()

    betamax_recorder.current_cassette.match_options.append('body')

    return betamax_recorder.session

I also fixed path manipulations failing tests on Windows (slash vs backslash separator).

@sigmavirus24 please advise.

Thank you.

sigmavirus24 commented 8 years ago

I also fixed path manipulations failing tests on Windows (slash vs backslash separator).

Please make that a separate pull request.

sigmavirus24 commented 8 years ago

@davidovich once you split the test fix into a separate pull request, I'll happily merge this. Ignore the python 3.2 failures, they're not you're fault. :)

davidovich commented 8 years ago

@sigmavirus24 I separated the windows test fix in a separate PR. thanks

sigmavirus24 commented 8 years ago

Thanks @davidovich!

davidovich commented 8 years ago

Thanks @sigmavirus24 By any chance, do you have an ETA for the 0.6 release?

sigmavirus24 commented 8 years ago

Not yet, @davidovich. We have an 0.6.0 milestone with one other item in it. I'm not going to require that feature land for 0.6.0 but it is a request that has been open for quite a while and I'd like to merge it in.