diff --git a/AUTHORS b/AUTHORS index c63c0a005..e5bf56a65 100644 --- a/AUTHORS +++ b/AUTHORS @@ -202,6 +202,7 @@ Stefan Zimmermann Stefano Taschini Steffen Allner Stephan Obermann +Sven-Hendrik Haase Tadek Teleżyński Tarcisio Fischer Tareq Alayan diff --git a/changelog/4188.feature.rst b/changelog/4188.feature.rst new file mode 100644 index 000000000..d3169efc0 --- /dev/null +++ b/changelog/4188.feature.rst @@ -0,0 +1 @@ +Make ``--color`` emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if ``--verbose`` was also passed. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 8deb330cc..d207dd785 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -263,7 +263,7 @@ class TerminalReporter(object): char = {"xfailed": "x", "skipped": "s"}.get(char, char) return char in self.reportchars - def write_fspath_result(self, nodeid, res): + def write_fspath_result(self, nodeid, res, **markup): fspath = self.config.rootdir.join(nodeid.split("::")[0]) if fspath != self.currentfspath: if self.currentfspath is not None and self._show_progress_info: @@ -272,7 +272,7 @@ class TerminalReporter(object): fspath = self.startdir.bestrelpath(fspath) self._tw.line() self._tw.write(fspath + " ") - self._tw.write(res) + self._tw.write(res, **markup) def write_ensure_prefix(self, prefix, extra="", **kwargs): if self.currentfspath != prefix: @@ -386,22 +386,22 @@ class TerminalReporter(object): # probably passed setup/teardown return running_xdist = hasattr(rep, "node") + if markup is None: + if rep.passed: + markup = {"green": True} + elif rep.failed: + markup = {"red": True} + elif rep.skipped: + markup = {"yellow": True} + else: + markup = {} if self.verbosity <= 0: if not running_xdist and self.showfspath: - self.write_fspath_result(rep.nodeid, letter) + self.write_fspath_result(rep.nodeid, letter, **markup) else: - self._tw.write(letter) + self._tw.write(letter, **markup) else: self._progress_nodeids_reported.add(rep.nodeid) - if markup is None: - if rep.passed: - markup = {"green": True} - elif rep.failed: - markup = {"red": True} - elif rep.skipped: - markup = {"yellow": True} - else: - markup = {} line = self._locationline(rep.nodeid, *rep.location) if not running_xdist: self.write_ensure_prefix(line, word, **markup)