Download tests/conftest.py from asmaakbar/phase-ll: direct link, hf CLI and curl.
- Browser
- Download file 768 Bytes
-
https://huggingface.co/spaces/asmaakbar/phase-ll/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/asmaakbar/phase-ll/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/asmaakbar/phase-ll/resolve/main/tests/conftest.py
768 Bytes
| import pytest | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker | |
| from sqlmodel import SQLModel | |
| from ..src.database.database import AsyncSessionLocal, async_engine | |
| from ..src.api.main import app | |
| def event_loop(): | |
| """Create an event loop for async tests.""" | |
| import asyncio | |
| loop = asyncio.new_event_loop() | |
| yield loop | |
| loop.close() | |
| def client(): | |
| """Create a test client for the API.""" | |
| from fastapi.testclient import TestClient | |
| with TestClient(app) as test_client: | |
| yield test_client | |
| async def async_session(): | |
| """Create an async database session for testing.""" | |
| async with AsyncSessionLocal() as session: | |
| yield session |