22
33import shutil
44from pathlib import Path
5- from typing import Iterator
65
7- import cocoindex as coco
86import pytest
97
108from cocoindex_code .config import _discover_codebase_root
1311
1412pytest_plugins = ("pytest_asyncio" ,)
1513
16-
17- @pytest .fixture (scope = "module" )
18- def coco_runtime () -> Iterator [None ]:
19- """Set up CocoIndex runtime context shared across all tests in this module."""
20- with coco .runtime ():
21- yield
22-
2314# === Sample codebase files ===
2415
2516SAMPLE_MAIN_PY = '''\
@@ -140,7 +131,7 @@ def setup_base_codebase(codebase: Path) -> None:
140131class TestEndToEnd :
141132 """End-to-end tests for the complete index-query workflow."""
142133
143- @pytest .mark .asyncio
134+ @pytest .mark .asyncio ( loop_scope = "session" )
144135 async def test_index_and_query_codebase (
145136 self , test_codebase_root : Path , coco_runtime : None
146137 ) -> None :
@@ -164,7 +155,7 @@ async def test_index_and_query_codebase(
164155 assert len (results ) > 0
165156 assert "database.py" in results [0 ].file_path
166157
167- @pytest .mark .asyncio
158+ @pytest .mark .asyncio ( loop_scope = "session" )
168159 async def test_incremental_update_add_file (
169160 self , test_codebase_root : Path , coco_runtime : None
170161 ) -> None :
@@ -190,7 +181,7 @@ async def test_incremental_update_add_file(
190181 assert len (results ) > 0
191182 assert "ml_model.py" in results [0 ].file_path
192183
193- @pytest .mark .asyncio
184+ @pytest .mark .asyncio ( loop_scope = "session" )
194185 async def test_incremental_update_modify_file (
195186 self , test_codebase_root : Path , coco_runtime : None
196187 ) -> None :
@@ -210,7 +201,7 @@ async def test_incremental_update_modify_file(
210201 content_lower = results [0 ].content .lower ()
211202 assert "authenticate" in content_lower or "login" in content_lower
212203
213- @pytest .mark .asyncio
204+ @pytest .mark .asyncio ( loop_scope = "session" )
214205 async def test_incremental_update_delete_file (
215206 self , test_codebase_root : Path , coco_runtime : None
216207 ) -> None :
0 commit comments