Skip to content

configure warnings as errors in the test suite #128770

Closed
@graingert

Description

@graingert

Feature or enhancement

Proposal:

It's very easy (especially when deprecating something) to introduce a lot of noisy test output with new warnings, eg: #127949 (comment)

I think it would be useful to either configure warnings as errors in the test suite (and then capture unraisable/threadexcept errors using a mechanism like pytest has) or tee any warnings produced, and fail CI if any have been produced that were not captured with catch_warnings or assertWarns etc like https://pypi.org/project/pytest-max-warnings/

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/its-too-easy-to-introduce-noise-in-cpythons-test-suite-output-resourcewarnings-and-deprecationwarnings/75234

Linked PRs

Activity

sobolevn

sobolevn commented on Jan 13, 2025

@sobolevn
Member

See #110012 test_socket raises warnings right now.

graingert

graingert commented on Jan 14, 2025

@graingert
ContributorAuthor

See #128816 test_doctest also has a warning

graingert

graingert commented on Jan 14, 2025

@graingert
ContributorAuthor

See #110012 test_socket raises warnings right now.

I'm thinking we mark these as default with catch_warnings in the test for now?

added a commit that references this issue on Jan 17, 2025

gh-128770: raise warnings as errors in test suite - except for test_s…

7807b40
added a commit that references this issue on Jan 17, 2025

pythongh-128770: raise warnings as errors in test suite - except for …

added a commit that references this issue on Jan 17, 2025

Revert "pythongh-128770: raise warnings as errors in test suite - exc…

added a commit that references this issue on Jan 17, 2025

Revert "gh-128770: raise warnings as errors in test suite - except fo…

76856ae
added a commit that references this issue on Jan 18, 2025

Reapply "pythongh-128770: raise warnings as errors in test suite - ex…

a6bb15e

19 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      configure warnings as errors in the test suite · Issue #128770 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant