Skip to content

Commit 92fc265

Browse files
HumanBean17claude
andcommitted
fix(tests): switch to asyncio_mode=strict to prevent kuzu segfault
The segfault was caused by pytest-asyncio creating background event loops for all tests when asyncio_mode=auto. Kuzu's C++ library conflicts with these background threads, causing segfaults during test execution. Solution: - Switch asyncio_mode from auto to strict in both pytest.ini files - Explicitly mark async test files with pytest.mark.asyncio: - tests/test_mcp_v2.py - tests/test_mcp_tools.py - tests/test_lancedb_e2e.py This prevents pytest-asyncio from creating event loops for kuzu tests while keeping asyncio working for tests that explicitly opt in. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent deadc75 commit 92fc265

5 files changed

Lines changed: 11 additions & 2 deletions

File tree

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[pytest]
2-
asyncio_mode = auto
2+
asyncio_mode = strict
33
testpaths = tests

tests/pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[pytest]
2-
asyncio_mode = auto
2+
asyncio_mode = strict
33
testpaths = .

tests/test_lancedb_e2e.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
reason="set JAVA_CODEBASE_RAG_RUN_HEAVY=1 to run the cocoindex + LanceDB end-to-end test",
3131
),
3232
pytest.mark.lance_e2e,
33+
pytest.mark.asyncio,
3334
]
3435

3536
CAPABILITY_SMOKE_ROOT = Path(__file__).resolve().parent / "fixtures" / "capability_smoke"

tests/test_mcp_tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
"""Tool-surface assertions for the v2 MCP API."""
22
from __future__ import annotations
33

4+
import pytest
5+
6+
# Mark all async tests in this module to use asyncio
7+
pytestmark = pytest.mark.asyncio
8+
49

510
def _enum_sets(node: object) -> list[set[str]]:
611
found: list[set[str]] = []

tests/test_mcp_v2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
from java_ontology import VALID_RESOLVE_REASONS
1818

19+
# Mark all async tests in this module to use asyncio
20+
pytestmark = pytest.mark.asyncio
21+
1922
from mcp_v2 import (
2023
Edge,
2124
NodeFilter,

0 commit comments

Comments
 (0)