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

Resolving Issue #11457 #11669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpourgoutzidis
Copy link

Hello,

This PR resolves #11457.

Description:

Essentially, the issue is that when the user calls .fail() and the test case has an internal error, they will receive the reason for failing passed to .fail() as well as the internal error context. The figure below was the test given to produce this behaviour:

TestToReplicateIssue

And the following figure is the behaviour itself:

ErroneousResult

Solution:

This was described as unfavourable, so to prevent this behaviour, I added a suppress context parameter to the .fail() function to allow users to choose whether they want to internal error context to be printed. Now, with running the same test, we choose to suppress the context:

TestWithNewFunctionality

This gives us the following result:

UpdatedResult

I believe this is an apt fix as suppress_context is set to False by default, meaning that it would not change the default behaviour, but gives the user more overall control of their text outputs.

Information

Head-fork: seanpourgoutzidis/pytest
compare: issue11457

base-fork: pytest-dev/pytest
base: main

Thanks,
Sean

@RonnyPfannschmidt
Copy link
Member

My understanding is that the correct way to do this is to use raise ... from None

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

Successfully merging this pull request may close these issues.

Option for pytest.fail to not print exception context
2 participants