File size: 1,442 Bytes
ade4f6a
 
 
 
fa3606d
 
3d1d87d
fa3606d
ade4f6a
 
 
 
ffcba68
ade4f6a
 
 
ffcba68
ade4f6a
ffcba68
ade4f6a
 
 
 
 
 
 
 
ffcba68
ade4f6a
 
 
ffcba68
ade4f6a
ffcba68
ade4f6a
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
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)
    )