From b48283f6269027cde2265c8f2163daaaed4d04f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 16 Nov 2019 16:43:46 +0100 Subject: [PATCH] tests: adapt inspect page test for py3 (#36515) --- tests/test_backoffice_pages.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_backoffice_pages.py b/tests/test_backoffice_pages.py index b061d9b04..24dea21de 100644 --- a/tests/test_backoffice_pages.py +++ b/tests/test_backoffice_pages.py @@ -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' ()") # don't show «unusable» variables assert 'form_f1' not in resp.text