Skip to content

Commit e0be457

Browse files
committed
[BUG](test): fix fastapi fixture registration and sqlite_fixture name
Three issues in chromadb/test/conftest.py broke test collection: fastapi, async_fastapi, and fastapi_persistent were plain functions without @pytest.fixture decorators. The system fixture uses request.getfixturevalue() with their names as params, which requires them to be registered fixtures. Without the decorator pytest raises 'fixture not found' at collection time. The same three functions used return instead of yield from, so the server teardown (system.stop() and proc.kill()) inside _fastapi_fixture never ran after tests completed. filtered_fixture_names() listed 'sqlite_fixture' which does not exist; the registered parameterized fixture is named 'sqlite'. Tests parameterized via the system fixture would skip the sqlite variant silently. Fixes: add @pytest.fixture() to the three functions, switch return to yield from, and rename 'sqlite_fixture' to 'sqlite' in the default fixture list. Fixes #7395
1 parent 8bb6aed commit e0be457

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

chromadb/test/conftest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,22 @@ def run(args: Any) -> Generator[System, None, None]:
387387
yield from run(args)
388388

389389

390+
@pytest.fixture()
390391
def fastapi() -> Generator[System, None, None]:
391-
return _fastapi_fixture(is_persistent=False)
392+
yield from _fastapi_fixture(is_persistent=False)
392393

393394

395+
@pytest.fixture()
394396
def async_fastapi() -> Generator[System, None, None]:
395-
return _fastapi_fixture(
397+
yield from _fastapi_fixture(
396398
is_persistent=False,
397399
chroma_api_impl="chromadb.api.async_fastapi.AsyncFastAPI",
398400
)
399401

400402

403+
@pytest.fixture()
401404
def fastapi_persistent() -> Generator[System, None, None]:
402-
return _fastapi_fixture(is_persistent=True)
405+
yield from _fastapi_fixture(is_persistent=True)
403406

404407

405408
def fastapi_ssl() -> Generator[System, None, None]:
@@ -753,7 +756,7 @@ def filtered_fixture_names() -> List[str]:
753756
"fastapi",
754757
"async_fastapi",
755758
"fastapi_persistent",
756-
"sqlite_fixture",
759+
"sqlite",
757760
"sqlite_persistent",
758761
]
759762

0 commit comments

Comments
 (0)