Skip to content

test(google-genai): skip the vcrpy aiohttp workaround on fixed vcrpy - #276

Open
pylaterreur wants to merge 1 commit into
alibaba:mainfrom
pylaterreur:google-genai-vcrpy-1055
Open

pylaterreur wants to merge 1 commit into
alibaba:mainfrom
pylaterreur:google-genai-vcrpy-1055

Conversation

@pylaterreur

Copy link
Copy Markdown

Description

tests/generate_content/test_e2e.py has an autouse fixture, patch_vcr_aiohttp_stream, that works around kevin1024/vcrpy#927 by subclassing vcrpy's MockStream and MockClientResponse. kevin1024/vcrpy#1055 (not released yet) fixes that bug in vcrpy itself: a replayed response keeps a single aiohttp StreamReader as content, and MockStream now takes the body. With it, the fixture makes every async replay fail with TypeError: MockStream.__init__() missing 1 required positional argument: 'body'. pytest-vcr doesn't pin vcrpy, so the -latest environments will pick up that release unchanged.

The fixture now returns early when vcrpy has the fix, detected with issubclass(aiohttp_stubs.MockStream, aiohttp.StreamReader) because the vcrpy version that will ship it isn't known yet. With vcrpy 8.3.0 nothing changes.

Upstream opentelemetry-python-contrib has since removed this package (open-telemetry/opentelemetry-python-contrib#5017). If you plan to drop it here too, feel free to close this.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

pytest instrumentation-genai/opentelemetry-instrumentation-google-genai/tests --vcr-record=none, offline, with the -latest dependencies, on Python 3.10, 3.12 and 3.14:

vcrpy before after
8.3.0 192 passed 192 passed
with kevin1024/vcrpy#1055 6 failed 192 passed

ruff and pylint are clean.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

@CLAassistant

CLAassistant commented Sep 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pylaterreur
pylaterreur force-pushed the google-genai-vcrpy-1055 branch from 6f7f63f to 1bcc693 Compare September 30, 2026 21:56
The patch_vcr_aiohttp_stream fixture in test_e2e.py works around
kevin1024/vcrpy#927. kevin1024/vcrpy#1055 fixes that bug in vcrpy
itself, and with it the fixture makes every async replay fail with a
TypeError. Skip the fixture when vcrpy's MockStream is an aiohttp
StreamReader, which is only the case with that fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

This branch has not been deployed

No deployments
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