diff --git a/README.md b/README.md index 5850f5734..0ab02908c 100644 --- a/README.md +++ b/README.md @@ -469,6 +469,12 @@ pre-commit install -t pre-push pysen run format lint ``` +## テスト + +```bash +python -m pytest +``` + ## タイポチェック [typos](https://github.com/crate-ci/typos) を使ってタイポのチェックを行っています。 diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py new file mode 100644 index 000000000..23fd4f042 --- /dev/null +++ b/test/e2e/conftest.py @@ -0,0 +1,24 @@ +from pathlib import Path + +import pytest +from fastapi.testclient import TestClient +from run import generate_app + +from voicevox_engine.setting import SettingLoader +from voicevox_engine.synthesis_engine import make_synthesis_engines +from voicevox_engine.utility.core_version_utility import get_latest_core_version + + +@pytest.fixture(scope="session") +def client(): + synthesis_engines = make_synthesis_engines(use_gpu=False) + latest_core_version = get_latest_core_version(versions=synthesis_engines.keys()) + setting_loader = SettingLoader(Path("./default_setting.yml")) + + return TestClient( + generate_app( + synthesis_engines=synthesis_engines, + latest_core_version=latest_core_version, + setting_loader=setting_loader, + ) + ) diff --git a/test/e2e/generate_test_client.py b/test/e2e/generate_test_client.py deleted file mode 100644 index c5a8e29ed..000000000 --- a/test/e2e/generate_test_client.py +++ /dev/null @@ -1,18 +0,0 @@ -from fastapi.testclient import TestClient -from run import generate_app - -from voicevox_engine.setting import SettingLoader -from voicevox_engine.synthesis_engine import make_synthesis_engines -from voicevox_engine.utility.core_version_utility import get_latest_core_version - -synthesis_engines = make_synthesis_engines(use_gpu=False) -latest_core_version = get_latest_core_version(versions=synthesis_engines.keys()) -setting_loader = SettingLoader("./e2e_test_setting.yml") - -client = TestClient( - generate_app( - synthesis_engines=synthesis_engines, - latest_core_version=latest_core_version, - setting_loader=setting_loader, - ) -) diff --git a/test/e2e/test_validate_version.py b/test/e2e/test_validate_version.py index f606b192a..b431a4a44 100644 --- a/test/e2e/test_validate_version.py +++ b/test/e2e/test_validate_version.py @@ -1,9 +1,9 @@ -from generate_test_client import client +from fastapi.testclient import TestClient from voicevox_engine import __version__ -def test_fetch_version_success(): +def test_fetch_version_success(client: TestClient): response = client.get("/version") assert response.status_code == 200 assert response.json() == __version__