parent
b5a02fb462
commit
3a4efa1d18
|
@ -30,6 +30,8 @@ from py.xml import html, raw
|
|||
from . import extras
|
||||
from . import __version__, __pypi_url__
|
||||
|
||||
from _pytest.logging import _remove_ansi_escape_sequences
|
||||
|
||||
|
||||
def pytest_addhooks(pluginmanager):
|
||||
from . import hooks
|
||||
|
@ -279,9 +281,13 @@ class HTMLReport:
|
|||
header, content = map(escape, section)
|
||||
log.append(f" {header:-^80} ")
|
||||
log.append(html.br())
|
||||
|
||||
if ANSI:
|
||||
converter = Ansi2HTMLConverter(inline=False, escaped=False)
|
||||
content = converter.convert(content, full=False)
|
||||
else:
|
||||
content = _remove_ansi_escape_sequences(content)
|
||||
|
||||
log.append(raw(content))
|
||||
log.append(html.br())
|
||||
|
||||
|
|
|
@ -830,6 +830,29 @@ class TestHTML:
|
|||
else:
|
||||
assert content not in html
|
||||
|
||||
def test_ansi_escape_sequence_removed(self, testdir):
|
||||
testdir.makeini(
|
||||
r"""
|
||||
[pytest]
|
||||
log_cli = 1
|
||||
log_cli_level = INFO
|
||||
"""
|
||||
)
|
||||
testdir.makepyfile(
|
||||
r"""
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
LOGGER = logging.getLogger()
|
||||
def test_ansi():
|
||||
LOGGER.info("ANSI removed")
|
||||
"""
|
||||
)
|
||||
result, html = run(
|
||||
testdir, "report.html", "--self-contained-html", "--color=yes"
|
||||
)
|
||||
assert result.ret == 0
|
||||
assert not re.search(r"\[[\d;]+m", html)
|
||||
|
||||
@pytest.mark.parametrize("content", [("'foo'"), ("u'\u0081'")])
|
||||
def test_utf8_longrepr(self, testdir, content):
|
||||
testdir.makeconftest(
|
||||
|
|
Loading…
Reference in New Issue