Fixed handling unicode longrepr values. Fixes #114.
This commit is contained in:
parent
4a16b04d1b
commit
a0cade6e0c
|
@ -219,9 +219,7 @@ class HTMLReport(object):
|
|||
def append_log_html(self, report, additional_html):
|
||||
log = html.div(class_='log')
|
||||
if report.longrepr:
|
||||
for line in str(report.longrepr).splitlines():
|
||||
if not PY3:
|
||||
line = line.decode('utf-8')
|
||||
for line in report.longreprtext.splitlines():
|
||||
separator = line.startswith('_ ' * 10)
|
||||
if separator:
|
||||
log.append(line[:80])
|
||||
|
|
|
@ -537,3 +537,23 @@ class TestHTML:
|
|||
assert content in html
|
||||
else:
|
||||
assert content not in html
|
||||
|
||||
@pytest.mark.parametrize('content', [("'foo'"), ("u'\u0081'")])
|
||||
def test_utf8_longrepr(self, testdir, content):
|
||||
testdir.makeconftest("""
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
if report.when == 'call':
|
||||
report.longrepr = 'utf8 longrepr: ' + {0}
|
||||
""".format(content))
|
||||
testdir.makepyfile("""
|
||||
def test_fail():
|
||||
testtext = 'utf8 longrepr: '
|
||||
assert False
|
||||
""")
|
||||
result, html = run(testdir, 'report.html', '--self-contained-html')
|
||||
assert result.ret
|
||||
assert 'utf8 longrepr' in html
|
||||
|
|
Loading…
Reference in New Issue