Closed juftin closed 7 months ago
Removes binary YAML entries on cassettes
import pathlib import yaml from vcr.filters import decode_response from vcr.serialize import deserialize, serialize from vcr.serializers import yamlserializer repo = pathlib.Path.home() / "git" / "camply" cassettes = list(repo.rglob("**/cassettes/*.yaml")) for cassette in cassettes: cassette_value = cassette.read_text() cassette_yaml = yaml.safe_load(cassette_value) requests, responses = deserialize(cassette_value, yamlserializer) for index, (request, response) in enumerate(zip(requests, responses)): decoded_response = decode_response(response) if isinstance(decoded_response["body"]["string"], bytes): string_value = decoded_response["body"]["string"].decode("utf-8") decoded_response["body"]["string"] = string_value responses[index] = decoded_response cassette_dict = dict( requests=requests, responses=responses, ) yaml_dump = serialize(cassette_dict, yamlserializer) cassette.write_text(yaml_dump)
:tada: This PR is included in version 0.32.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Description
Removes binary YAML entries on cassettes