|
|
import time |
|
|
from pathlib import Path |
|
|
import pytest |
|
|
|
|
|
from lib.audio import play_audio_until_end, get_length |
|
|
from lib.pages import TranslatorPage |
|
|
from test_data.audio_clips.audio_list import test_audios, audio_texts |
|
|
from lib.report import AccuracyReport, AccuracyItem |
|
|
|
|
|
@pytest.mark.parametrize("audio", test_audios.get("zh")) |
|
|
def test_accuracy_zh2en(app, page: TranslatorPage, accuracy_report: AccuracyReport, audio:Path): |
|
|
page.start_zh2en() |
|
|
translation_lang = "zh2en" |
|
|
play_audio_until_end(audio) |
|
|
time.sleep(4) |
|
|
page.set_off() |
|
|
zh, en = page.get_translated_texts(translation_lang) |
|
|
accuracy_report.items.append( |
|
|
AccuracyItem(translation_type=translation_lang, audio=audio.name, |
|
|
audio_length=get_length(audio), audio_text=audio_texts.get(audio.stem), |
|
|
src_text=zh, dst_text=en) |
|
|
) |
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("audio", test_audios.get("en")) |
|
|
def test_accuracy_en2zh(app, page: TranslatorPage, accuracy_report: AccuracyReport, audio): |
|
|
page.start_en2zh() |
|
|
translation_lang = "en2zh" |
|
|
play_audio_until_end(audio) |
|
|
time.sleep(4) |
|
|
page.set_off() |
|
|
en, zh = page.get_translated_texts(translation_lang) |
|
|
accuracy_report.items.append( |
|
|
AccuracyItem(translation_type=translation_lang, audio=audio.name, |
|
|
audio_length=get_length(audio), audio_text=audio_texts.get(audio.stem), |
|
|
src_text=en, dst_text=zh) |
|
|
) |
|
|
|
|
|
|
|
|
|