wmt-2020-pl-en/tests/test_gtoken.py

58 lines
933 B
Python

# -*- coding: utf-8 -*-
from googletrans import gtoken
from pytest import fixture
@fixture
def acquirer():
return gtoken.TokenAcquirer()
def test_acquire_token(acquirer):
text = 'test'
result = acquirer.do(text)
assert result
def test_acquire_token_ascii_less_than_2048(acquirer):
text = u'Ѐ'
result = acquirer.do(text)
assert result
def test_acquire_token_ascii_matches_special_condition(acquirer):
text = chr(55296) + chr(56320)
result = acquirer.do(text)
assert result
def test_acquire_token_ascii_else(acquirer):
text = u''
result = acquirer.do(text)
assert result
def test_reuse_valid_token(acquirer):
text = 'test'
first = acquirer.do(text)
second = acquirer.do(text)
assert first == second
def test_map_lazy_return(acquirer):
value = True
func = acquirer._lazy(value)
assert callable(func)
assert func() == value