Merge branch 'master' into hotfix-batch-words
Browse files
deep_translator/parent.py
CHANGED
@@ -64,7 +64,7 @@ class BaseTranslator(ABC):
|
|
64 |
@param max_chars: maximum characters allowed
|
65 |
@return: bool
|
66 |
"""
|
67 |
-
return True if min_chars
|
68 |
|
69 |
@abstractmethod
|
70 |
def translate(self, text, **kwargs):
|
|
|
64 |
@param max_chars: maximum characters allowed
|
65 |
@return: bool
|
66 |
"""
|
67 |
+
return True if min_chars <= len(payload) < max_chars else False
|
68 |
|
69 |
@abstractmethod
|
70 |
def translate(self, text, **kwargs):
|
deep_translator/tests/test_google_trans.py
CHANGED
@@ -58,3 +58,7 @@ def test_payload(google_translator):
|
|
58 |
|
59 |
#for _ in range(1):
|
60 |
#assert google_translator.translate(text='좋은') == "good"
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
#for _ in range(1):
|
60 |
#assert google_translator.translate(text='좋은') == "good"
|
61 |
+
|
62 |
+
|
63 |
+
def test_one_character_words():
|
64 |
+
assert GoogleTranslator(source='es', target='en').translate('o') == 'or'
|
deep_translator/tests/test_linguee.py
CHANGED
@@ -49,6 +49,10 @@ def test_payload(linguee):
|
|
49 |
linguee.translate("a"*51)
|
50 |
|
51 |
|
|
|
52 |
def test_translate_words(linguee):
|
53 |
words = ['hello', 'world']
|
54 |
translated_words = linguee.translate_words(words)
|
|
|
|
|
|
|
|
49 |
linguee.translate("a"*51)
|
50 |
|
51 |
|
52 |
+
|
53 |
def test_translate_words(linguee):
|
54 |
words = ['hello', 'world']
|
55 |
translated_words = linguee.translate_words(words)
|
56 |
+
|
57 |
+
def test_one_character_words():
|
58 |
+
assert LingueeTranslator(source='es', target='en').translate('y') == 'and'
|
deep_translator/tests/test_mymemory.py
CHANGED
@@ -46,3 +46,8 @@ def test_payload(mymemory):
|
|
46 |
|
47 |
with pytest.raises(exceptions.NotValidLength):
|
48 |
mymemory.translate(text="a"*501)
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
with pytest.raises(exceptions.NotValidLength):
|
48 |
mymemory.translate(text="a"*501)
|
49 |
+
|
50 |
+
|
51 |
+
def test_one_character_words(mymemory):
|
52 |
+
assert mymemory.translate('I')
|
53 |
+
|
deep_translator/tests/test_pons.py
CHANGED
@@ -48,6 +48,10 @@ def test_payload(pons):
|
|
48 |
pons.translate("a" * 51)
|
49 |
|
50 |
|
|
|
51 |
def test_translate_words(pons):
|
52 |
words = ['hello', 'world']
|
53 |
translated_words = pons.translate_words(words)
|
|
|
|
|
|
|
|
48 |
pons.translate("a" * 51)
|
49 |
|
50 |
|
51 |
+
|
52 |
def test_translate_words(pons):
|
53 |
words = ['hello', 'world']
|
54 |
translated_words = pons.translate_words(words)
|
55 |
+
|
56 |
+
def test_one_character_words(pons):
|
57 |
+
assert pons.translate('I')
|