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

Configure pytest to fail on warnings #3903

Merged
merged 4 commits into from
Oct 18, 2023
Merged

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Oct 17, 2023

What

This PR configures pytest such that it fails if a warning is emitted (e.g. a deprecation warning).

  • add the relevant pytest config in our pyproject.toml
  • add -c path/to/pyproject.toml in pytest invocations (justfile and CI)
  • fix ugly two instances of "file not closed" warnings

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@abey79 abey79 added 🧑‍💻 dev experience developer experience (excluding CI) include in changelog labels Oct 17, 2023
# https://docs.python.org/3/library/warnings.html#warning-filter
filterwarnings = """
error
ignore::pytest.PytestUnraisableExceptionWarning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any more context why this one is ignored?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context is that I've been lazy and discarded this error as what I initially (mis-)read as some internal Pytest stuff. It turns out they were caused by two nasty instance of us not closing files properly, which I now fixed.

Thanks for not letting me be lazy.

Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

@Wumpf Wumpf merged commit 65fccf2 into main Oct 18, 2023
32 checks passed
@Wumpf Wumpf deleted the antoine/pytest-fail-on-warning branch October 18, 2023 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) include in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants