Show session duration in human-readable format

Fix #5707
This commit is contained in:
Bruno Oliveira
2019-08-10 09:14:57 -03:00
parent 8665f5652a
commit 345df99db7
6 changed files with 43 additions and 12 deletions

View File

@@ -340,7 +340,10 @@ def _config_for_test():
config._ensure_unconfigure() # cleanup, e.g. capman closing tmpfiles.
rex_outcome = re.compile(r"(\d+) ([\w-]+)")
# regex to match the session duration string in the summary: "74.34s"
rex_session_duration = re.compile(r"\d+\.\d\ds")
# regex to match all the counts and phrases in the summary line: "34 passed, 111 skipped"
rex_outcome = re.compile(r"(\d+) (\w+)")
class RunResult:
@@ -379,14 +382,11 @@ class RunResult:
"""
for line in reversed(self.outlines):
if "seconds" in line:
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
if outcomes:
d = {}
for num, cat in outcomes:
d[cat] = int(num)
return d
raise ValueError("Pytest terminal report not found")
return {noun: int(count) for (count, noun) in outcomes}
raise ValueError("Pytest terminal summary report not found")
def assert_outcomes(
self, passed=0, skipped=0, failed=0, error=0, xpassed=0, xfailed=0