|
34 | 34 |
|
35 | 35 | @pytest.fixture(autouse=True) |
36 | 36 | def setup_test_container(test_settings): |
37 | | - """Override DI-injected settings for services resolved through the container. |
38 | | -
|
39 | | - Uses ``container.use_overrides`` so that pre-existing overrides are |
40 | | - snapshot-restored automatically on teardown without touching private state. |
41 | | -
|
42 | | - Note: ``codeweaver.core.get_settings()`` constructs settings directly from |
43 | | - the installed package configuration and does *not* consult this container, |
44 | | - so this override only affects services that receive their settings via DI |
45 | | - resolution. Code paths that call ``get_settings()`` directly (e.g. |
46 | | - ``CheckpointManager._extract_fingerprint``) must be patched separately. |
47 | | - """ |
48 | | - from codeweaver.core.config.settings_type import CodeWeaverSettingsType |
| 37 | + """Create test DI container and override settings so real `get_settings()` works.""" |
49 | 38 | from codeweaver.core.di.container import get_container |
50 | | - |
| 39 | + from codeweaver.core.config.settings_type import CodeWeaverSettingsType |
51 | 40 |
|
52 | 41 | container = get_container() |
53 | | - with container.use_overrides({CodeWeaverSettingsType: test_settings}): |
54 | | - yield container |
| 42 | + container.override(CodeWeaverSettingsType, test_settings) |
| 43 | + yield container |
| 44 | + container.clear() |
55 | 45 |
|
56 | 46 |
|
57 | 47 | @pytest.fixture |
@@ -218,13 +208,9 @@ def mock_vector_store() -> AsyncMock: |
218 | 208 |
|
219 | 209 |
|
220 | 210 | @pytest.fixture |
221 | | -def test_settings() -> NonCallableMock: |
222 | | - """Create test Settings with default configuration. |
223 | | -
|
224 | | - Uses ``NonCallableMock`` so the DI container does not invoke the object as |
225 | | - a factory when resolving ``CodeWeaverSettingsType``. |
226 | | - """ |
227 | | - settings = NonCallableMock() |
| 211 | +def test_settings() -> Mock: |
| 212 | + """Create test Settings with default configuration.""" |
| 213 | + settings = Mock() |
228 | 214 |
|
229 | 215 | # Provider settings |
230 | 216 | settings.provider = Mock() |
|
0 commit comments