Skip to content

Conversation

@tito
Copy link

@tito tito commented Jan 22, 2025

This pull request aims to resolve an issue with using VCR.py in conjunction with io-like data.
Let's have a look at this example:

@vcr.use_cassette("issue_vcr_aiohttp.yaml")
def test():
    test = io.BytesIO(b"hello")
    async with aiohttp.ClientSession() as session:
        async with session.post("https://httpbin.org/post", data=test, json=None) as response:
            ret = await response.json()
            assert ret["data"] == "hello"

It will trigger the assert, because the body received by aiohttp will be empty.
When using cassette and building Request, the body is read() and later usage of body by aiohttp won't work.

Fix provided with the help of @kevdevg

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.

2 participants