diff --git a/packages/python/e2e-attestations/claude-1330-python-extensions-patch.json b/packages/python/e2e-attestations/claude-1330-python-extensions-patch.json new file mode 100644 index 000000000..88912da29 --- /dev/null +++ b/packages/python/e2e-attestations/claude-1330-python-extensions-patch.json @@ -0,0 +1,7 @@ +{ + "command": "uv run python -m pytest tests/e2e/capture_collision_test.py tests/e2e/fanout_test.py tests/e2e/cli_version_test.py tests/e2e/extension_package_test.py tests/e2e/on_file_query_test.py tests/e2e/sigint_interrupt_test.py tests/e2e/plugin_extension_discovery_test.py tests/e2e/plugin_discovery_test.py tests/e2e/query_contract_test.py -x -q", + "ran_at": 1791302302, + "exit_code": 0, + "commit": "97413988a4b984de31f96d190d2164d61279d7c5", + "branch": "claude/1330-python-extensions-patch" +} diff --git a/packages/python/testing-conventions.toml b/packages/python/testing-conventions.toml index 28308a5d6..96cd99c4e 100644 --- a/packages/python/testing-conventions.toml +++ b/packages/python/testing-conventions.toml @@ -13,8 +13,3 @@ extra_scope = ["packages/rust/src", "packages/python/src", "packages/python/test [python.coverage] fail_under = 100 branch = true - -[[python.exempt]] -path = "tests/integration/hermetic/extensions_test.py" -rules = ["no-first-party-patch"] -reason = "the hermetic tier IS the _RustDirSQL core-boundary patch; no third-party target exists to move it to" diff --git a/packages/python/tests/integration/hermetic/extensions_test.py b/packages/python/tests/integration/hermetic/extensions_test.py index 7143a2eff..804d13f39 100644 --- a/packages/python/tests/integration/hermetic/extensions_test.py +++ b/packages/python/tests/integration/hermetic/extensions_test.py @@ -51,9 +51,16 @@ def _reset_instances(): @pytest.fixture def mock_core(): - """Replace the Rust-backed ``_RustDirSQL`` alias in ``dirsql._async``.""" - with patch.object(async_mod, "_RustDirSQL", _FakeRustDirSQL): - yield _FakeRustDirSQL + """Build the wrapper with a fake core through its factory seam.""" + return _wrapper_with_core(_FakeRustDirSQL) + + +def _wrapper_with_core(core_factory): + class WrapperWithCore(async_mod.DirSQL): + def _new_core(self, root, **kwargs): + return core_factory(root, **kwargs) + + return WrapperWithCore @pytest.fixture @@ -98,14 +105,14 @@ def describe_extensions_kwarg(): # packages/python/README.md. @pytest.mark.asyncio async def it_defaults_extensions_to_none(mock_core): - db = async_mod.DirSQL("/root", tables=["t"]) + db = mock_core("/root", tables=["t"]) await db.ready() assert _FakeRustDirSQL.instances[0].extensions is None @pytest.mark.asyncio async def it_forwards_literal_paths_verbatim(mock_core, mock_cwd): - db = async_mod.DirSQL( + db = mock_core( "/root", tables=["t"], extensions=[{"path": "/abs/libvec.so", "entrypoint": "sqlite3_vec_init"}], @@ -118,9 +125,7 @@ async def it_forwards_literal_paths_verbatim(mock_core, mock_cwd): @pytest.mark.asyncio async def it_defaults_a_missing_entrypoint_to_none(mock_core, mock_cwd): - db = async_mod.DirSQL( - "/root", tables=["t"], extensions=[{"path": "./rel/libvec.so"}] - ) + db = mock_core("/root", tables=["t"], extensions=[{"path": "./rel/libvec.so"}]) await db.ready() assert _FakeRustDirSQL.instances[0].extensions == [ @@ -136,9 +141,7 @@ async def it_resolves_a_bare_package_name_to_the_installed_loadable( ) mock_glob.return_value = ["/site-packages/sqlite_vec/vec0.so"] - db = async_mod.DirSQL( - "/root", tables=["t"], extensions=[{"path": "sqlite_vec"}] - ) + db = mock_core("/root", tables=["t"], extensions=[{"path": "sqlite_vec"}]) await db.ready() assert _FakeRustDirSQL.instances[0].extensions == [ @@ -151,9 +154,7 @@ async def it_prefers_a_same_named_local_file_over_the_package( ): mock_isfile.return_value = True - db = async_mod.DirSQL( - "/root", tables=["t"], extensions=[{"path": "sqlite_vec"}] - ) + db = mock_core("/root", tables=["t"], extensions=[{"path": "sqlite_vec"}]) await db.ready() assert _FakeRustDirSQL.instances[0].extensions == [ @@ -170,7 +171,7 @@ async def it_resolves_config_extension_package_names_and_suppresses_core_loading ) mock_glob.return_value = ["/site-packages/sqlite_vec/vec0.so"] - db = async_mod.DirSQL(config="/cfg/.dirsql.toml") + db = mock_core(config="/cfg/.dirsql.toml") await db.ready() inst = _FakeRustDirSQL.instances[0] @@ -185,7 +186,7 @@ async def it_rejects_ready_when_a_bare_package_name_is_not_installed( ): mock_find_spec.return_value = None - db = async_mod.DirSQL("/root", tables=["t"], extensions=[{"path": "nope"}]) + db = mock_core("/root", tables=["t"], extensions=[{"path": "nope"}]) with pytest.raises(ValueError, match="not installed"): await db.ready()