Spaces:
Running
on
Zero
Running
on
Zero
File size: 938 Bytes
4c346eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import importlib
import os
from collections.abc import Iterator
from unittest.mock import patch
import pytest
from fastapi.testclient import TestClient
@pytest.fixture(name="test_client", scope="session")
def fixture_test_client() -> Iterator[TestClient]:
# Lazily import from aviary so typeguard doesn't throw:
# > /path/to/.venv/lib/python3.11/site-packages/typeguard/_pytest_plugin.py:93:
# > InstrumentationWarning: typeguard cannot check these packages
# > because they are already imported: ether0
import ether0.clients # noqa: PLC0415
from ether0.server import app # noqa: PLC0415
client = TestClient(app)
with patch.dict(
os.environ,
{
"ETHER0_REMOTES_API_BASE_URL": str(client.base_url),
"ETHER0_REMOTES_API_TOKEN": "test_stub",
},
):
importlib.reload(ether0.clients) # Pull in updated environment variables
yield client
|