Fix: Color E(xecption) lines in the log red (#631)

This commit is contained in:
Jim Brännlund 2023-04-08 18:16:57 +02:00 committed by GitHub
parent 8350dda5eb
commit 5f580273a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -95,7 +95,9 @@ const dom = {
resultBody.querySelector('.col-duration').innerText = duration < 1 ? formatDuration(duration).ms : formatDuration(duration).formatted
if (log) {
resultBody.querySelector('.log').innerHTML = log
// Wrap lines starting with "E" with span.error to color those lines red
const wrappedLog = log.replace(/^E.*$/gm, (match) => `<span class="error">${match}</span>`)
resultBody.querySelector('.log').innerHTML = wrappedLog
} else {
resultBody.querySelector('.log').remove()
}

View File

@ -206,6 +206,9 @@ class TestHTML:
page = run(pytester)
assert_results(page, failed=1)
assert_that(get_log(page)).contains("AssertionError")
assert_that(get_text(page, ".summary div[class='log'] span.error")).matches(
r"^E\s+assert False$"
)
def test_xfail(self, pytester):
reason = str(random.random())