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

Add the before_handle_response option #594

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akaihola
Copy link

@akaihola akaihola commented Jul 5, 2021

Fixes #544.

The problem

Currently callbacks defined using the before_record_response can modify responses, but this creates an inconsistency where e.g. unit test cases see unmodified responses when cassettes are being recorded, and modified ones when they are later played back.

The solution

The before_handle_response can be used to define callbacks instead. The response modifications now apply equally to live responses when recording cassettes as well as played back responses later:

def vcr_config():
    return {
        "before_handle_response": [my_callback],
    }

This is an alternative to the alter_live_response = True option implemented in #595.

@akaihola akaihola force-pushed the before_handle_response branch from c688950 to da11e7c Compare March 16, 2023 16:47
@kevin1024 kevin1024 force-pushed the master branch 3 times, most recently from df3997c to 34d5384 Compare June 26, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

before_record_response returns inconsistent data depending on recording or not
1 participant