Skip to content

Commit d158910

Browse files
committed
Color the steps independently of the scenario
- use the output of the individual steps to decide the output colour
1 parent 538deec commit d158910

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pytest_bdd/gherkin_terminal_reporter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ def pytest_runtest_logreport(self, report):
102102
self._tw.write(report.scenario["name"], **scenario_markup)
103103
self._tw.write("\n")
104104
for step in report.scenario["steps"]:
105+
step_markup = (
106+
{"red": True} if step["failed"] else ({"yellow": True} if step["skipped"] else {"green": True})
107+
)
105108
if self.config.option.expand:
106109
step_name = self._format_step_name(step["name"], **report.scenario["example_kwargs"])
107110
else:
108111
step_name = step["name"]
109-
self._tw.write(" {} {}\n".format(step["keyword"], step_name), **scenario_markup)
112+
self._tw.write(" {} {}\n".format(step["keyword"], step_name), **step_markup)
110113
self._tw.write(" " + word, **word_markup)
111114
self._tw.write("\n\n")
112115
else:

0 commit comments

Comments
 (0)