Skip to content

Fix DI container override callable and private API access in config validation tests#209

Merged
bashandbone merged 3 commits intofix-test-triage-and-issues-4039835176754165263from
copilot/sub-pr-207
Mar 10, 2026
Merged

Fix DI container override callable and private API access in config validation tests#209
bashandbone merged 3 commits intofix-test-triage-and-issues-4039835176754165263from
copilot/sub-pr-207

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

The setup_test_container fixture was using Mock() for test_settings, causing the DI container to invoke it as a factory (container calls any non-type callable override), returning a different Mock instance instead of the intended settings object. The fixture was also manually snapshotting/restoring container._overrides (private attribute) instead of using the public context manager API.

Changes

  • test_settingsNonCallableMock: Prevents Container._resolve_override from treating the settings object as a factory callable. The container returns the mock directly rather than calling it.

  • setup_test_containeruse_overrides context manager: Replaces manual _overrides dict snapshot/restore with container.use_overrides({CodeWeaverSettingsType: test_settings}), which handles atomic save/restore in its finally block.

# Before: manual private-state manipulation
initial_overrides = dict(container._overrides) if hasattr(container, "_overrides") else {}
container.override(CodeWeaverSettingsType, test_settings)  # test_settings is callable → called as factory
yield container
container.clear_overrides()
for interface, instance in initial_overrides.items():
    container.override(interface, instance)

# After: public API, non-callable mock
with container.use_overrides({CodeWeaverSettingsType: test_settings}):  # NonCallableMock → returned directly
    yield container

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…n test fixtures

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix test setup and DI container issues in test suite Fix DI container override callable and private API access in config validation tests Mar 10, 2026
@bashandbone bashandbone marked this pull request as ready for review March 10, 2026 01:51
Copilot AI review requested due to automatic review settings March 10, 2026 01:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two bugs in the setup_test_container and test_settings fixtures in the config validation integration tests. The Mock() object used for settings was being invoked as a factory by the DI container (which calls any non-type callable override), and the fixture was manually manipulating private container state for override save/restore.

Changes:

  • Changed test_settings from Mock() to NonCallableMock() to prevent the DI container from treating the settings mock as a factory callable.
  • Replaced manual _overrides dict snapshot/restore with the public container.use_overrides() context manager, consistent with other integration test files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…pilot/sub-pr-207

Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
@bashandbone bashandbone merged commit 3a7b5bf into fix-test-triage-and-issues-4039835176754165263 Mar 10, 2026
4 of 5 checks passed
@github-actions
Copy link
Contributor

👋 Hey @Copilot,

Thanks for your contribution to codeweaver! 🧵

You need to agree to the CLA first... 🖊️

Before we can accept your contribution, you need to agree to our Contributor License Agreement (CLA).

To agree to the CLA, please comment:

I read the contributors license agreement and I agree to it.

Those exact words are important1, so please don't change them. 😉

You can read the full CLA here: Contributor License Agreement


✅ @Copilot has signed the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Footnotes

  1. Our bot needs those exact words to recognize that you agree to the CLA.

@bashandbone bashandbone deleted the copilot/sub-pr-207 branch March 10, 2026 02:18
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants