-
Notifications
You must be signed in to change notification settings - Fork 59
/
test.py
64 lines (52 loc) · 2.33 KB
/
test.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import translatepy
t = translatepy.Translator()
def test_translate():
print("[test] --> Testing Translator.translate")
assert t.translate("Hello", "Japanese", "French") is not None
assert t.translate("", "Japanese", "French") is None
assert t.translate(" ", "Japanese", "French") is None
assert t.translate("Hello", "French", "Japanese") is not None
assert t.translate("Hello", "ja", "fr") is not None
def test_language():
print("[test] --> Testing Translator.language")
assert t.language("Hello") is not None
def test_Language():
print("[test] --> Testing translatepy.Language")
assert translatepy.Language("French").language == "fr"
assert translatepy.Language("Japanese").language == "ja"
assert translatepy.Language("en").language == "en"
assert translatepy.Language("japanese").language == "ja"
assert translatepy.AUTOMATIC.japanese == "自動"
def test_spellcheck():
print("[test] --> Testing Translator.spellcheck")
assert t.spellcheck("Hello") is not None
assert t.spellcheck("God morning") is not None
def test_example():
print("[test] --> Testing Translator.example")
assert t.example("Hello", "japanese") is not None
def test_dictionary():
print("[test] --> Testing Translator.dictionary")
#assert t.dictionary("Hello", "Japanese") is not None
# I can't test dictionary as DeepL is very strict on their rate-limit
def test_text_to_speech():
print("[test] --> Testing Translator.text_to_speech")
assert t.text_to_speech("Hello, how are you?", "English") is not None
def test_imports():
print("[test] --> Testing imports")
from translatepy.data import data
from translatepy.models import exceptions
from translatepy.models import languages
from translatepy.translators import bing
from translatepy.translators import deepl
from translatepy.translators import google
from translatepy.translators import reverso
from translatepy.translators import unselected
from translatepy.translators import yandex
from translatepy.utils import annotations
from translatepy.utils import similarity
from translatepy import translate
import translatepy
def test_yandex_ucid():
print("[test] --> Testing Translator.yandex_translate._sid")
t = translatepy.Translator()
assert t.yandex_translate._ucid() is not None