Fix DI container override callable and private API access in config validation tests#209
Conversation
…n test fixtures Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
There was a problem hiding this comment.
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_settingsfromMock()toNonCallableMock()to prevent the DI container from treating the settings mock as a factory callable. - Replaced manual
_overridesdict snapshot/restore with the publiccontainer.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>
3a7b5bf
into
fix-test-triage-and-issues-4039835176754165263
|
👋 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:
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
|
The
setup_test_containerfixture was usingMock()fortest_settings, causing the DI container to invoke it as a factory (container calls any non-type callable override), returning a differentMockinstance instead of the intended settings object. The fixture was also manually snapshotting/restoringcontainer._overrides(private attribute) instead of using the public context manager API.Changes
test_settings→NonCallableMock: PreventsContainer._resolve_overridefrom treating the settings object as a factory callable. The container returns the mock directly rather than calling it.setup_test_container→use_overridescontext manager: Replaces manual_overridesdict snapshot/restore withcontainer.use_overrides({CodeWeaverSettingsType: test_settings}), which handles atomic save/restore in itsfinallyblock.💡 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.