From 7576b01f72a69b5f556e98ce90f5983c209d217e Mon Sep 17 00:00:00 2001 From: ssut Date: Fri, 5 Jun 2015 23:42:53 +0900 Subject: [PATCH] add test cases --- .travis.yml | 8 ++++++++ tests.py | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .travis.yml create mode 100644 tests.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2a27f7a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: python +python: + - "2.7" + - "3.4" + - "pypy" +install: + - "pip install ." +script: "python tests.py -v" diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..5627d87 --- /dev/null +++ b/tests.py @@ -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()