add test cases
This commit is contained in:
parent
fa13d07e70
commit
7576b01f72
8
.travis.yml
Normal file
8
.travis.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- "2.7"
|
||||||
|
- "3.4"
|
||||||
|
- "pypy"
|
||||||
|
install:
|
||||||
|
- "pip install ."
|
||||||
|
script: "python tests.py -v"
|
26
tests.py
Normal file
26
tests.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import unittest
|
||||||
|
from googletrans import translator
|
||||||
|
|
||||||
|
class TranslateTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_latin_to_english(self):
|
||||||
|
result = translator.translate('veritas lux mea', src='la', dest='en')
|
||||||
|
assert result.text == 'The truth is my light'
|
||||||
|
|
||||||
|
def test_unicode(self):
|
||||||
|
result = translator.translate(u'안녕하세요.', src='ko', dest='ja')
|
||||||
|
assert result.text == 'こんにちは。'
|
||||||
|
|
||||||
|
def test_list_translation(self):
|
||||||
|
translations = translator.translate(['The quick brown fox', 'jumps over', 'the lazy dog'],
|
||||||
|
src='en', dest='ko')
|
||||||
|
|
||||||
|
assert translations[0].text == u'빠른 갈색 여우'
|
||||||
|
assert translations[1].text == u'이상 점프'
|
||||||
|
assert translations[2].text == u'게으른 개'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user