tests: adapt test_json_str_decoder for py3 (#36515)
This commit is contained in:
parent
a55daeec35
commit
859683f690
|
@ -9,6 +9,8 @@ import time
|
|||
import datetime
|
||||
import base64
|
||||
|
||||
from django.utils import six
|
||||
|
||||
from quixote import cleanup
|
||||
|
||||
import wcs.api # workaround against circular dependencies :/
|
||||
|
@ -18,7 +20,7 @@ from wcs.qommon.misc import (simplify, json_loads, parse_isotime, format_time,
|
|||
date_format, get_as_datetime, normalize_geolocation)
|
||||
from wcs.admin.settings import FileTypesDirectory
|
||||
from wcs.scripts import Script
|
||||
from wcs.qommon import evalutils
|
||||
from wcs.qommon import force_str, evalutils
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.backoffice.listing import pagination_links
|
||||
from wcs.qommon.emails import email as send_email, docutils
|
||||
|
@ -112,13 +114,14 @@ def test_json_str_decoder():
|
|||
'lst': [{'a': 'b'}, 1, 2],
|
||||
'bla': u'éléphant'
|
||||
})
|
||||
assert type(json.loads(json_str).keys()[0]) is unicode
|
||||
assert type(json.loads(json_str)['lst'][0]['a']) is unicode
|
||||
if six.PY2:
|
||||
assert type(list(json.loads(json_str).keys())[0]) is unicode
|
||||
assert type(json.loads(json_str)['lst'][0]['a']) is unicode
|
||||
|
||||
assert type(json_loads(json_str).keys()[0]) is str
|
||||
assert type(list(json_loads(json_str).keys())[0]) is str
|
||||
assert type(json_loads(json_str)['lst'][0]['a']) is str
|
||||
assert type(json_loads(json_str)['bla']) is str
|
||||
assert json_loads(json_str)['bla'] == u'éléphant'.encode('utf-8')
|
||||
assert json_loads(json_str)['bla'] == force_str(u'éléphant')
|
||||
|
||||
def test_format_time():
|
||||
assert format_time(None, '%(month_name)s') == '?'
|
||||
|
|
Loading…
Reference in New Issue