I know about pytest -s
. However, I would like to let a hook print to the console.
The following didn't work for me:
terminal_reporter = request.config.pluginmanager.getplugin("terminalreporter")
terminal_reporter.write_line("TEST")
This still needed pytest -s
to run. Instead I'd like to circumvent that.
Specifically, I'm overwriting the pytest_bdd_before_scenario()
hook to print the steps that are being executed.
For the hooks that are not involved in test execution (configuration, reporting etc) writing with terminal reporter should work. However, once the test starts (and capturing is enabled), the output capturing mechanism is invoked, and there's no exception made for the terminal reporter. To be able to write to terminal, you need to disable capturing temporarily. Example: