Open akaihola opened 1 year ago
Describe the bug If I use a before_record_response= callback which modifies the response, the original response is used when the response is being recorded, and the modified response when it's being played back.
before_record_response=
To Reproduce Steps to reproduce the behavior:
On this test file test_modified_response.py:
test_modified_response.py
import pytest import requests def modify_response(response): response["body"]["string"] = b"Modified response" return response @pytest.mark.vcr(before_record_response=[modify_response]) def test_modified_response(): response = requests.get( "https://github.com/kiwicom/pytest-recording", headers={"Accept-Encoding": "identity"}, # prevent compression ) assert response.content == b"Modified response"
pytest --record-mode=once test_modified_response.py
.yaml
response: body: string: Modified response
pytest test_modified_response.py
Expected behavior For the example above, both test runs should pass.
More generally, the modified response should be returned to the calling HTTP client also when it's being recorded.
Environment (please complete the following information):
This is actually probably better fixed on the VCRpy side – see kevin1024/vcrpy#544.
Describe the bug If I use a
before_record_response=
callback which modifies the response, the original response is used when the response is being recorded, and the modified response when it's being played back.To Reproduce Steps to reproduce the behavior:
On this test file
test_modified_response.py
:.yaml
file has the modified content:Expected behavior For the example above, both test runs should pass.
More generally, the modified response should be returned to the calling HTTP client also when it's being recorded.
Environment (please complete the following information):