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

self = <tests.unit.cli.test_bench.TestBenchCommand object at 0x10bd68f30>
tmp_path = PosixPath('/private/var/folders/1q/2qhztsp1673fnqgrpblxnpd40000gn/T/pytest-of-forrest/pytest-344/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 0x10cc39900>('encoding')
E        +    where <built-in method get of dict object at 0x10cc39900> = {}.get

fixture    = {'queries': [{'query': 'test', 'relevant_docids': ['doc-1']}]}
fixture_opens = [{}]
fixture_path = PosixPath('/private/var/folders/1q/2qhztsp1673fnqgrpblxnpd40000gn/T/pytest-of-forrest/pytest-344/test_bench_fixture_open_pins_u0/fixture.json')
mock_db    = <MagicMock id='4491604192'>
mock_manager = <MagicMock id='4491604528'>
mock_pipeline = <MagicMock id='4491602848'>
real_open  = <built-in function open>
result     = <Result okay>
runner     = <click.testing.CliRunner object at 0x10bb86a50>
self       = <tests.unit.cli.test_bench.TestBenchCommand object at 0x10bd68f30>
spy_open   = <function TestBenchCommand.test_bench_fixture_open_pins_utf8_encoding.<locals>.spy_open at 0x10cf3a7a0>
tmp_path   = PosixPath('/private/var/folders/1q/2qhztsp1673fnqgrpblxnpd40000gn/T/pytest-of-forrest/pytest-344/test_bench_fixture_open_pins_u0')

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.11s
