-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
133 additions
and
28 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
crates/voicevox_core_python_api/python/test/test_pseudo_raii_for_synthesizer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
``Synthesizer`` について、(広義の)RAIIができることをテストする。 | ||
""" | ||
|
||
import conftest | ||
import pytest | ||
import pytest_asyncio | ||
from voicevox_core import OpenJtalk, Synthesizer, VoicevoxError | ||
|
||
|
||
def test_enter_returns_workable_self(synthesizer: Synthesizer) -> None: | ||
with synthesizer as ctx: | ||
assert ctx is synthesizer | ||
_ = synthesizer.metas | ||
|
||
|
||
def test_closing_multiple_times_is_allowed(synthesizer: Synthesizer) -> None: | ||
with synthesizer: | ||
with synthesizer: | ||
pass | ||
synthesizer.close() | ||
synthesizer.close() | ||
|
||
|
||
def test_access_after_close_denied(synthesizer: Synthesizer) -> None: | ||
synthesizer.close() | ||
with pytest.raises(VoicevoxError, match="^The `Synthesizer` is closed$"): | ||
_ = synthesizer.metas | ||
|
||
|
||
def test_access_after_exit_denied(synthesizer: Synthesizer) -> None: | ||
with synthesizer: | ||
pass | ||
with pytest.raises(VoicevoxError, match="^The `Synthesizer` is closed$"): | ||
_ = synthesizer.metas | ||
|
||
|
||
@pytest_asyncio.fixture | ||
async def synthesizer(open_jtalk: OpenJtalk) -> Synthesizer: | ||
return await Synthesizer.new_with_initialize(open_jtalk) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def open_jtalk() -> OpenJtalk: | ||
return OpenJtalk(conftest.open_jtalk_dic_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters