tests: adapt inspect page test for py3 (#36515)

This commit is contained in:
Frédéric Péters 2019-11-16 16:43:46 +01:00
parent 30a9d2d4c3
commit b48283f626
1 changed files with 10 additions and 4 deletions

View File

@ -18,6 +18,7 @@ try:
except ImportError:
xlwt = None
from django.utils import six
from django.utils.six import StringIO, BytesIO
from django.utils.six.moves.urllib import parse as urllib
from django.utils.six.moves.urllib import parse as urlparse
@ -4246,7 +4247,7 @@ def test_inspect_page(pub, local_user):
formdata.data['3_structured'] = {
'unicode': u'uné',
'str_but_non_utf8': '\xed\xa0\x00',
'str_but_non_utf8': b'\xed\xa0\x00', # not actually supposed to happen
'non_unicode_convertible': IHateUnicode(),
'very_long_string': '0' * 100000,
}
@ -4279,9 +4280,14 @@ def test_inspect_page(pub, local_user):
assert (pq('[title="form_var_foo_non_unicode_convertible"]')
.parents('li').children('div.value span')
.text().startswith('ok '))
assert (pq('[title="form_var_foo_str_but_non_utf8"]')
.parents('li').children('div.value span')
.text() == '\'\\xed\\xa0\\x00\'')
if six.PY2:
assert (pq('[title="form_var_foo_str_but_non_utf8"]')
.parents('li').children('div.value span')
.text() == '\'\\xed\\xa0\\x00\'')
else:
assert (pq('[title="form_var_foo_str_but_non_utf8"]')
.parents('li').children('div.value span')
.text() == "b'\\xed\\xa0\\x00' (<class 'bytes'>)")
# don't show «unusable» variables
assert 'form_f1' not in resp.text