Skip to content

Commit bf2057a

Browse files
dsax7hristiy4n
authored andcommitted
Color the steps independently of the scenario
- use the output of the individual steps to decide the output colour
1 parent 0a8a4e3 commit bf2057a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pytest_bdd/gherkin_terminal_reporter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ def pytest_runtest_logreport(self, report: TestReport) -> Any:
9393
self._tw.write(report.scenario["name"], **scenario_markup)
9494
self._tw.write("\n")
9595
for step in report.scenario["steps"]:
96-
self._tw.write(f" {step['keyword']} {step['name']}\n", **scenario_markup)
96+
step_markup = (
97+
{"red": True} if step["failed"] else ({"yellow": True} if step["skipped"] else {"green": True})
98+
)
99+
self._tw.write(f" {step['keyword']} {step['name']}\n", **step_markup)
97100
self._tw.write(" " + word, **word_markup)
98101
self._tw.write("\n\n")
99102
else:

0 commit comments

Comments
 (0)