conftest.py 534 B

123456789101112131415161718192021
  1. from __future__ import annotations
  2. import os
  3. from typing import Iterator
  4. import pytest
  5. from fastapi.testclient import TestClient
  6. # Use MySQL test database from environment or default
  7. os.environ.setdefault(
  8. "DATABASE_URL", "mysql+asyncmy://root:hn02le.34lkdLKD@121.43.228.102:3306/dibang-test?charset=utf8mb4"
  9. )
  10. os.environ.setdefault("ENV", "test")
  11. from app.main import app # noqa: E402
  12. @pytest.fixture(scope="module")
  13. def client() -> Iterator[TestClient]:
  14. with TestClient(app) as test_client:
  15. yield test_client