Skip to content

Commit 48dee00

Browse files
committed
Color the steps independently of the scenario
- use the output of the individual steps to decide the output colour
1 parent 96039fd commit 48dee00

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pytest_bdd/gherkin_terminal_reporter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ 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 = {'red': True} if step["failed"] else (
106+
{"yellow": True} if step["skipped"] else {"green": True})
105107
if self.config.option.expand:
106108
step_name = self._format_step_name(step["name"], **report.scenario["example_kwargs"])
107109
else:
108110
step_name = step["name"]
109-
self._tw.write(" {} {}\n".format(step["keyword"], step_name), **scenario_markup)
111+
self._tw.write(" {} {}\n".format(step["keyword"], step_name), **step_markup)
110112
self._tw.write(" " + word, **word_markup)
111113
self._tw.write("\n\n")
112114
else:

0 commit comments

Comments
 (0)