From b128722a0d31bdaca3157ced90f7ec67a2406721 Mon Sep 17 00:00:00 2001 From: SuHun Han Date: Fri, 10 Mar 2017 22:53:00 +0900 Subject: [PATCH] Fix tests that occurs unicode error in python 2.x --- tests/test_client.py | 5 +++-- tests/test_gtoken.py | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 3d83623..b55a8cd 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -21,12 +21,13 @@ def test_translate_list(translator): def test_detect_language(translator): - ko = translator.detect('한국어') + ko = translator.detect(u'한국어') en = translator.detect('English') assert ko.lang == 'ko' assert en.lang == 'en' + def test_detect_list(translator): items = [u'한국어', ' English'] @@ -63,4 +64,4 @@ def test_dest_not_in_supported_languages(translator): args = ('Hello', 'zzz', 'en') with raises(ValueError): - translator.translate(*args) \ No newline at end of file + translator.translate(*args) diff --git a/tests/test_gtoken.py b/tests/test_gtoken.py index 8649fd6..2fdbfa0 100644 --- a/tests/test_gtoken.py +++ b/tests/test_gtoken.py @@ -25,7 +25,12 @@ def test_acquire_token_ascii_less_than_2048(acquirer): def test_acquire_token_ascii_matches_special_condition(acquirer): - text = chr(55296) + chr(56320) + def unichar(i): + try: + return unichr(i) + except NameError: + return chr(i) + text = unichar(55296) + unichar(56320) result = acquirer.do(text) @@ -55,4 +60,4 @@ def test_map_lazy_return(acquirer): func = acquirer._lazy(value) assert callable(func) - assert func() == value \ No newline at end of file + assert func() == value