From fd0b3e2e8bab00693d3b5bcea47e5aa94eb42f7c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 14 Apr 2019 23:15:31 +0200 Subject: [PATCH 1/3] getreportopt: remove needless if --- src/_pytest/terminal.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 2d7132259..c2d0d0ce1 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -165,15 +165,14 @@ def getreportopt(config): reportchars += "w" elif config.option.disable_warnings and "w" in reportchars: reportchars = reportchars.replace("w", "") - if reportchars: - for char in reportchars: - if char == "a": - reportopts = "sxXwEf" - elif char == "A": - reportopts = "sxXwEfpP" - break - elif char not in reportopts: - reportopts += char + for char in reportchars: + if char == "a": + reportopts = "sxXwEf" + elif char == "A": + reportopts = "sxXwEfpP" + break + elif char not in reportopts: + reportopts += char return reportopts From cc78a533aee7e40d8412262552d3e86cba37f409 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 14 Apr 2019 23:17:09 +0200 Subject: [PATCH 2/3] terminal: summary_errors: replace if with assert --- src/_pytest/terminal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index c2d0d0ce1..fe3996238 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -851,7 +851,8 @@ class TerminalReporter(object): msg = "ERROR collecting " + msg elif rep.when == "setup": msg = "ERROR at setup of " + msg - elif rep.when == "teardown": + else: + assert rep.when == "teardown", "Unexpected rep: %r" % (rep,) msg = "ERROR at teardown of " + msg self.write_sep("_", msg, red=True, bold=True) self._outrep_summary(rep) From 7412df092040bbb1f29bdc6de32068a3761c2b9a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 15 Apr 2019 22:53:31 +0200 Subject: [PATCH 3/3] fixup! terminal: summary_errors: replace if with assert --- src/_pytest/terminal.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index fe3996238..a238b38f5 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -849,11 +849,8 @@ class TerminalReporter(object): msg = self._getfailureheadline(rep) if rep.when == "collect": msg = "ERROR collecting " + msg - elif rep.when == "setup": - msg = "ERROR at setup of " + msg else: - assert rep.when == "teardown", "Unexpected rep: %r" % (rep,) - msg = "ERROR at teardown of " + msg + msg = "ERROR at %s of %s" % (rep.when, msg) self.write_sep("_", msg, red=True, bold=True) self._outrep_summary(rep)