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

Clarify the need for mix_stderr in when accessing the output of stderr in tests #1045

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mrchrisadams
Copy link

@mrchrisadams mrchrisadams commented Nov 8, 2024

This pull request includes a small change to the docs/tutorial/testing.md file. The change updates the documentation to clarify how to check for output sent to standard error when using CliRunner.

Documentation update:

  • docs/tutorial/testing.md: Clarified that the CliRunner instance must be created with the mix_stderr=False argument to access result.stderr in tests.

Why would this change be necessary?

I've made this because I was left scratching my head trying to test the output of stderr today in a project using Typer, and I only found the solution when I came across #385 an issue that was filed in 2022.

I looked for a better exception to raise, but it looks like this more a problem with Click's Result class than Typer; after looking into the codebase there didn't seem to be an obvious place in Typer to create a new, clearer exception class.

So, I've tried to go for some clearer text in the docs instead.

This is the before:

Screenshot 2024-11-08 at 18 44 06

This is the after:

Screenshot 2024-11-08 at 18 43 43

@github-actions github-actions bot added the docs Improvements or additions to documentation label Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant