Fix tests that occurs unicode error in python 2.x

This commit is contained in:
SuHun Han 2017-03-10 22:53:00 +09:00 committed by ssut
parent 1303d0cfdd
commit b128722a0d
2 changed files with 10 additions and 4 deletions

View File

@ -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)
translator.translate(*args)

View File

@ -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
assert func() == value