Skip to content

fix(test): correct async context manager mocking for bedrock routing#253

Merged
zxqfd555 merged 1 commit into
pathwaycom:mainfrom
iapoorv01:fix-bedrock-top-k
Jun 30, 2026
Merged

fix(test): correct async context manager mocking for bedrock routing#253
zxqfd555 merged 1 commit into
pathwaycom:mainfrom
iapoorv01:fix-bedrock-top-k

Conversation

@iapoorv01

Copy link
Copy Markdown
Contributor

Context

This PR resolves a persistent CI failure (AttributeError: __aenter__) in the test_bedrock_dynamic_args_routing test suite.

The test previously mocked the Bedrock client session using standard AsyncMock behavior, which can be unstable when resolving async context managers across different Python/Pytest environments. Because the BedrockChat production code evaluates async with self._session.client("bedrock-runtime") as client:, the mocked client must implement strict asynchronous context manager protocols. This PR explicitly constructs and injects a deterministic async context manager (__aenter__ and __aexit__) to guarantee stable test execution.

How has this been tested?

  • Unit Testing: Executed local test suites against python/pathway/xpacks/llm/tests/test_llms.py to confirm the manual MagicMock correctly satisfies the async with context evaluation without raising AttributeError exceptions.
  • Linting: Verified full compliance with the repository's formatting pipelines via black and flake8.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issue(s):

  1. Resolves CI instability introduced by fix(llms): dynamic routing of Bedrock model-specific inference args (e.g., top_k) #248

Checklist:

  • My code follows the code style of this project,
  • My change requires a change to the documentation,
  • I described the modification in the CHANGELOG.md file.

@zxqfd555 zxqfd555 merged commit 97aebcd into pathwaycom:main Jun 30, 2026
8 checks passed
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