Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Rich to write colored text to terminal from step definition not working #1078

Closed
stenaksel opened this issue Dec 22, 2022 · 1 comment
Labels

Comments

@stenaksel
Copy link

In my stepDefinitions I have tried to use rich for writing out to terminal with color. And I experienced Behave is working differently when I run it with --wip.
In a steps.py file add from rich import print as rprint and then in a step definition add rprint('[italic red]Hello[/italic red] World!')

Running Behave with --wip will show the red italic "Hello", but running without --wip will not...

I find this to be a bug...

@jenisys
Copy link
Member

jenisys commented Dec 22, 2022

The --wip changes a number of internal configurations if this option is enabled.
For example, it disables the stdout-capture, etc.

Normally, output from steps is captured and only shown if the step fails.
Try running behave --no-capture -f plain ... and you should see printed output.

OTHERWISE:

  • Provide and use your own formatter class that always shows captured-output.

@jenisys jenisys closed this as completed Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants