15549dcdf8
* Fix for invalid token array of the text * Remove unused compacted-json decoder because Google apparently now does not send like that before. This commit refers the issue #37. * Remove a test case for multiline text This is a temporary fix: will be reverted after mocking tests. * Add pipenv supports * Update README
25 lines
585 B
Python
25 lines
585 B
Python
from googletrans import utils
|
|
from pytest import raises
|
|
|
|
|
|
def test_format_json():
|
|
text = '[,,"en",,,,0.96954316,,[["en"],,[0.96954316]]]'
|
|
|
|
result = utils.legacy_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.legacy_format_json(text)
|
|
|
|
def test_rshift():
|
|
value, n = 1000, 3
|
|
|
|
result = utils.rshift(value, n)
|
|
|
|
assert result == 125
|