Spaces:
Sleeping
Sleeping
Download tests/conftest.py from fmbishu/image-search-api: direct link, hf CLI and curl.
- Browser
- Download file 846 Bytes
-
https://huggingface.co/spaces/fmbishu/image-search-api/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/fmbishu/image-search-api/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/fmbishu/image-search-api/resolve/main/tests/conftest.py
846 Bytes
| from __future__ import annotations | |
| import os | |
| import sys | |
| from collections.abc import Generator | |
| from pathlib import Path | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| # Ensure project root is on PYTHONPATH for `import app` | |
| ROOT_DIR = Path(__file__).resolve().parents[1] | |
| if str(ROOT_DIR) not in sys.path: | |
| sys.path.insert(0, str(ROOT_DIR)) | |
| os.environ.setdefault("DISABLE_STARTUP_EVENTS", "true") | |
| from app import main # noqa: E402 | |
| from app.database.models import ProductDatabase # noqa: E402 | |
| def client(tmp_path) -> Generator[TestClient, None, None]: | |
| db_path = tmp_path / "products.db" | |
| main.product_database = ProductDatabase(str(db_path)) | |
| main.product_catalog = [] | |
| main.product_id_to_index = {} | |
| main.reindexing = False | |
| with TestClient(main.app) as test_client: | |
| yield test_client | |