wmt-2020-pl-en/tests/test_utils.py
SuHun Han e10c5e8fa7
chore: v3.0.0 (#181)
Co-authored-by: Kirill Bobrov <miaplanedo@gmail.com>
Co-authored-by: Zhuopsticks <36221214+terryyz@users.noreply.github.com>
2020-06-14 15:42:32 +09:00

41 lines
809 B
Python

from googletrans import utils
from pytest import raises
def test_format_json():
text = '[,,"en",,,,0.96954316,,[["en"],,[0.96954316]]]'
result = utils.format_json(text)
assert result == [None, None, 'en', None, None, None, 0.96954316, None,
[['en'], None, [0.96954316]]]
def test_format_malformed_json():
text = '[,,"en",,,,0.96954316,,[["en"],,0.96954316]]]'
with raises(ValueError):
utils.format_json(text)
def test_rshift():
value, n = 1000, 3
result = utils.rshift(value, n)
assert result == 125
def test_build_params_with_override():
params = utils.build_params(
query='',
src='',
dest='',
token='',
override={
'otf': '3',
},
)
assert params['otf'] == '3'