Decode all bytes strings in extra text.

This commit is contained in:
Chingiz_Toimbetov 2017-08-08 15:06:54 +03:00 committed by Dave Hunt
parent 40e0ec3d1c
commit e9b2433549
2 changed files with 6 additions and 2 deletions

View File

@ -198,6 +198,8 @@ class HTMLReport(object):
elif extra.get('format') == extras.FORMAT_TEXT:
content = extra.get('content')
if isinstance(content, bytes):
content = content.decode("utf-8")
if self.self_contained:
href = data_uri(content)
else:

View File

@ -238,7 +238,8 @@ class TestHTML:
@pytest.mark.parametrize('content, encoded', [
("u'\u0081'", 'woE='),
("'foo'", 'Zm9v')])
("'foo'", 'Zm9v'),
("b'\\xe2\\x80\\x93'", "4oCT")])
def test_extra_text(self, testdir, content, encoded):
testdir.makeconftest("""
import pytest
@ -325,7 +326,8 @@ class TestHTML:
src = 'data:{0};base64,{1}'.format(mime_type, content)
assert '<img src="{0}"/>'.format(src) in html
@pytest.mark.parametrize('content', [("u'\u0081'"), ("'foo'")])
@pytest.mark.parametrize('content', [("u'\u0081'"), ("'foo'"),
("b'\\xe2\\x80\\x93'")])
def test_extra_text_separated(self, testdir, content):
testdir.makeconftest("""
import pytest