diff --git a/test/preset/test_preset.py b/test/preset/test_preset.py index 5318669b3..9938037d9 100644 --- a/test/preset/test_preset.py +++ b/test/preset/test_preset.py @@ -60,9 +60,9 @@ def test_not_exist_file() -> None: def test_add_preset(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": 10, @@ -83,7 +83,7 @@ def test_add_preset(tmp_path: Path) -> None: for _preset in preset_manager.presets: if _preset.id == id: assert _preset == preset - remove(temp_path) + remove(preset_path) def test_add_preset_load_failure() -> None: @@ -109,9 +109,9 @@ def test_add_preset_load_failure() -> None: def test_add_preset_conflict_id(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": 2, @@ -132,13 +132,13 @@ def test_add_preset_conflict_id(tmp_path: Path) -> None: for _preset in preset_manager.presets: if _preset.id == id: assert _preset == preset - remove(temp_path) + remove(preset_path) def test_add_preset_conflict_id2(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": -1, @@ -159,13 +159,13 @@ def test_add_preset_conflict_id2(tmp_path: Path) -> None: for _preset in preset_manager.presets: if _preset.id == id: assert _preset == preset - remove(temp_path) + remove(preset_path) def test_add_preset_write_failure(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": 10, @@ -187,13 +187,13 @@ def test_add_preset_write_failure(tmp_path: Path) -> None: with pytest.raises(PresetInternalError, match=true_msg): preset_manager.add_preset(preset) assert len(preset_manager.presets) == 2 - remove(temp_path) + remove(preset_path) def test_update_preset(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": 1, @@ -214,7 +214,7 @@ def test_update_preset(tmp_path: Path) -> None: for _preset in preset_manager.presets: if _preset.id == id: assert _preset == preset - remove(temp_path) + remove(preset_path) def test_update_preset_load_failure() -> None: @@ -240,9 +240,9 @@ def test_update_preset_load_failure() -> None: def test_update_preset_not_found(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": 10, @@ -261,13 +261,13 @@ def test_update_preset_not_found(tmp_path: Path) -> None: with pytest.raises(PresetInputError, match=true_msg): preset_manager.update_preset(preset) assert len(preset_manager.presets) == 2 - remove(temp_path) + remove(preset_path) def test_update_preset_write_failure(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset = Preset( **{ "id": 1, @@ -290,17 +290,17 @@ def test_update_preset_write_failure(tmp_path: Path) -> None: preset_manager.update_preset(preset) assert len(preset_manager.presets) == 2 assert preset_manager.presets[0].name == "test" - remove(temp_path) + remove(preset_path) def test_delete_preset(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) id = preset_manager.delete_preset(1) assert id == 1 assert len(preset_manager.presets) == 1 - remove(temp_path) + remove(preset_path) def test_delete_preset_load_failure() -> None: @@ -311,20 +311,20 @@ def test_delete_preset_load_failure() -> None: def test_delete_preset_not_found(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) true_msg = "削除対象のプリセットが存在しません" with pytest.raises(PresetInputError, match=true_msg): preset_manager.delete_preset(10) assert len(preset_manager.presets) == 2 - remove(temp_path) + remove(preset_path) def test_delete_preset_write_failure(tmp_path: Path) -> None: - temp_path = tmp_path / "presets-test-temp.yaml" - copyfile(presets_test_1_yaml_path, temp_path) - preset_manager = PresetManager(preset_path=temp_path) + preset_path = tmp_path / "presets.yaml" + copyfile(presets_test_1_yaml_path, preset_path) + preset_manager = PresetManager(preset_path=preset_path) preset_manager.load_presets() preset_manager._refresh_cache = lambda: None # type:ignore[method-assign] preset_manager.preset_path = "" # type: ignore[assignment] @@ -332,4 +332,4 @@ def test_delete_preset_write_failure(tmp_path: Path) -> None: with pytest.raises(PresetInternalError, match=true_msg): preset_manager.delete_preset(1) assert len(preset_manager.presets) == 2 - remove(temp_path) + remove(preset_path) diff --git a/test/setting/test_setting.py b/test/setting/test_setting.py index 677c2b3d3..dc2247c21 100644 --- a/test/setting/test_setting.py +++ b/test/setting/test_setting.py @@ -80,17 +80,6 @@ def test_setting_handler_save(tmp_path: Path) -> None: assert true_setting == setting -def test_setting_handler_load_cors_policy_mode_type() -> None: - """`SettingHandler.load()` で正しい型の値を得られる。""" - # Inputs - setting_path = Path("test/setting/setting-test-load-1.yaml") - setting_loader = SettingHandler(setting_path) - # Outputs - setting = setting_loader.load() - # Test - assert isinstance(setting.cors_policy_mode, CorsPolicyMode) - - def test_setting_invalid_input() -> None: """`Setting` は不正な入力に対してエラーを送出する。""" # Test diff --git a/test/tts_pipeline/test_mora_mapping.py b/test/tts_pipeline/test_mora_mapping.py index 0254a4f1c..d9baceb82 100644 --- a/test/tts_pipeline/test_mora_mapping.py +++ b/test/tts_pipeline/test_mora_mapping.py @@ -13,6 +13,6 @@ def test_mora2text() -> None: def test_mora2text_injective() -> None: """異なるモーラが同じ読みがなに対応しないか確認する""" - values = list(mora_phonemes_to_mora_kana.values()) - uniq_values = list(set(values)) - assert sorted(values) == sorted(uniq_values) + mora_kanas = list(mora_phonemes_to_mora_kana.values()) + # NOTE: 同じ読みがなが複数回登場すると set で非重複化して全長が短くなる + assert len(mora_kanas) == len(set(mora_kanas)) diff --git a/test/tts_pipeline/test_text_analyzer.py b/test/tts_pipeline/test_text_analyzer.py index 202b7fed6..5b017cffc 100644 --- a/test/tts_pipeline/test_text_analyzer.py +++ b/test/tts_pipeline/test_text_analyzer.py @@ -229,13 +229,13 @@ def test_mora_label_features() -> None: accent_phrase_hiho = AccentPhraseLabel.from_labels(labels_hello_hiho[11:19]) -def test_accentphrase_accent() -> None: +def test_accent_phrase_accent() -> None: """AccentPhraseLabel に含まれるアクセント位置をテスト""" assert accent_phrase_hello.accent == 5 assert accent_phrase_hiho.accent == 1 -def test_accentphrase_phonemes() -> None: +def test_accent_phrase_phonemes() -> None: """AccentPhraseLabel に含まれる音素系列をテスト""" outputs_hello = space_jointed_phonemes(accent_phrase_hello) outputs_hiho = space_jointed_phonemes(accent_phrase_hiho) @@ -243,7 +243,7 @@ def test_accentphrase_phonemes() -> None: assert outputs_hiho == "h i h o d e s U" -def test_accentphrase_features() -> None: +def test_accent_phrase_features() -> None: """AccentPhraseLabel に含まれる features をテスト""" expects = test_case_hello_hiho assert features(accent_phrase_hello) == expects[1:10] @@ -254,7 +254,7 @@ def test_accentphrase_features() -> None: breath_group_hiho = BreathGroupLabel.from_labels(labels_hello_hiho[11:19]) -def test_breathgroup_phonemes() -> None: +def test_breath_group_phonemes() -> None: """BreathGroupLabel に含まれる音素系列をテスト""" outputs_hello = space_jointed_phonemes(breath_group_hello) outputs_hiho = space_jointed_phonemes(breath_group_hiho) @@ -262,7 +262,7 @@ def test_breathgroup_phonemes() -> None: assert outputs_hiho == "h i h o d e s U" -def test_breathgroup_features() -> None: +def test_breath_group_features() -> None: """BreathGroupLabel に含まれる features をテスト""" expects = test_case_hello_hiho assert features(breath_group_hello) == expects[1:10]