Skip to content

Optional pytest and better-exceptions integration for MultipleFailures #3130

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

Merged
merged 5 commits into from
Nov 22, 2021

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Nov 1, 2021

We now respect the pytest --tb={no,short,native,auto,long} configuration; or if you aren't using pytest but do have better-exceptions active we'll use that. Closes #3116.

As a bonus: tries to detect light-colored terminal backgrounds, and prints ghostwritten code with light-theme syntax highlighting. This doesn't always work, but it's a lot better than the status quo of assuming a dark background and there's a clear place for future improvements.

@Zac-HD Zac-HD added legibility make errors helpful and Hypothesis grokable interop how to play nicely with other packages labels Nov 1, 2021
@Zac-HD Zac-HD requested a review from rsokl November 1, 2021 04:54
@Zac-HD Zac-HD changed the title Teach ghostwriter light theme Optional pytest and better-exceptions integration for MultipleFailures Nov 1, 2021
@Zac-HD Zac-HD force-pushed the better-multierror-reporting branch from c10a6e2 to cc5ac17 Compare November 1, 2021 11:26
@rsokl
Copy link
Contributor

rsokl commented Nov 9, 2021

If it isn't too much work, can you provide a minimal reproducible example so that I can be sure that I am exercising the pytest/better-exceptions functionality that this PR targets?

@Zac-HD
Copy link
Member Author

Zac-HD commented Nov 9, 2021

# example.py
from hypothesis import given, strategies as st

@given(st.integers())
def test(x):
    assert x > 0
    assert x < 0

if __name__ == "__main__":
    test()
pytest example.py --tb=short
pytest example.py --tb=long

python example.py
BETTER_EXCEPTIONS=1 python example.py

@Zac-HD Zac-HD force-pushed the better-multierror-reporting branch from cc5ac17 to 16db25e Compare November 15, 2021 12:38
@Zac-HD Zac-HD merged commit e5b4e88 into HypothesisWorks:master Nov 22, 2021
@Zac-HD Zac-HD deleted the better-multierror-reporting branch November 22, 2021 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop how to play nicely with other packages legibility make errors helpful and Hypothesis grokable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve traceback printing for MultipleFailures
2 participants