F                                                                        [100%]
=================================== FAILURES ===================================
_________ TestBenchCommand.test_bench_fixture_open_pins_utf8_encoding __________

self = <tests.unit.cli.test_bench.TestBenchCommand object at 0x1159d9010>
tmp_path = PosixPath('/private/var/folders/1q/2qhztsp1673fnqgrpblxnpd40000gn/T/pytest-of-forrest/pytest-346/test_bench_fixture_open_pins_u0')

    def test_bench_fixture_open_pins_utf8_encoding(self, tmp_path: Path) -> None:
        """Pin the WR-06 encoding sub-item via a locale-independent open contract.
    
        A functional non-ASCII fixture test would be vacuous on UTF-8 locales
        (the locale default already decodes UTF-8), so this spies on
        builtins.open and asserts the fixture open carries encoding="utf-8".
        """
        runner = CliRunner()
    
        fixture = {
            "queries": [
                {"query": "test", "relevant_docids": ["doc-1"]},
            ],
        }
        fixture_path = tmp_path / "fixture.json"
        fixture_path.write_text(json.dumps(fixture), encoding="utf-8")
    
        real_open = builtins.open
        fixture_opens: list[dict] = []
    
        def spy_open(file: object, *args: object, **kwargs: object) -> object:
            """Record the fixture open's kwargs; delegate every call unchanged."""
            if isinstance(file, (str, os.PathLike)) and os.fspath(file) == str(fixture_path):
                fixture_opens.append(kwargs)
            return real_open(file, *args, **kwargs)
    
        mock_pipeline = MagicMock()
        mock_pipeline.search.return_value = [
            MagicMock(document_id="doc-1"),
        ]
    
        mock_db = MagicMock()
        mock_manager = MagicMock()
        mock_manager.embed_single.return_value = [0.0] * 384
        mock_manager._model = MagicMock()
    
        with (
            patch("sif.cli.commands.bench.Database", return_value=mock_db),
            patch(
                "sif.cli.commands.bench.EmbeddingManager.from_settings",
                return_value=mock_manager,
            ),
            patch("sif.cli.commands.bench.SearchPipeline", return_value=mock_pipeline),
            patch("sif.cli.commands.bench.get_settings", return_value=_settings_mock()),
            patch("builtins.open", spy_open),
        ):
            result = runner.invoke(
                bench_cmd,
                [str(fixture_path)],
                obj={"index_path": MagicMock(exists=lambda: True)},
            )
    
        assert result.exit_code == 0
        assert len(fixture_opens) == 1
>       assert fixture_opens[0].get("encoding") == "utf-8"
E       AssertionError: assert None == 'utf-8'
E        +  where None = <built-in method get of dict object at 0x1159aca40>('encoding')
E        +    where <built-in method get of dict object at 0x1159aca40> = {}.get

tests/unit/cli/test_bench.py:586: AssertionError
=========================== short test summary info ============================
FAILED tests/unit/cli/test_bench.py::TestBenchCommand::test_bench_fixture_open_pins_utf8_encoding
1 failed, 34 deselected in 0.08s
