GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — configure warnings as errors in the test suite · Issue #128770 · python/cpython

configure warnings as errors in the test suite #128770

New issue
Copy link
New issue
Copy link
Closed
Closed
configure warnings as errors in the test suite#128770
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@graingert
graingert
opened on Jan 13, 2025
Issue body actions

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

  • gh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings #128726
  • gh-128770: fix ResourceWarning in test_pyrepl #128906
  • [3.13] gh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings (GH-128726) #128935
  • Revert "gh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings (#128726)" #128936
  • gh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings, and internal test warnings that are now logged #128973
  • [3.13] gh-128770: fix ResourceWarning in test_pyrepl (GH-128906) #129179
  • [3.13] gh-128770: raise warnings as errors in test suite - except for test_s… #131802
  • [3.12] gh-128770: raise warnings as errors in test suite - except for test_s… #131824

Activity

  1. graingert
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 13, 2025
  2. erlend-aasland
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Jan 13, 2025
  3. sobolevn commented on Jan 13, 2025

    @sobolevn
    sobolevn
    on Jan 13, 2025
    Member
    More actions

    See #110012 test_socket raises warnings right now.

  4. graingert commented on Jan 14, 2025

    @graingert
    graingert
    on Jan 14, 2025
    ContributorAuthor
    More actions

    See #128816 test_doctest also has a warning

  5. graingert commented on Jan 14, 2025

    @graingert
    graingert
    on Jan 14, 2025
    ContributorAuthor
    More actions

    See #110012 test_socket raises warnings right now.

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

  6. hugovk
    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
  7. miss-islington
    added a commit that references this issue on Jan 17, 2025

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

    128244d
  8. hugovk
    added 2 commits that reference this issue on Jan 17, 2025

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

    0342073

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

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

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

    a6bb15e
  10. srinivasreddy
    added 2 commits that reference this issue on Jan 21, 2025

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

    f12e00e

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

    076d0eb
  11. pablogsal
    added a commit that references this issue on Jan 22, 2025

    gh-128770: fix ResourceWarning in test_pyrepl (#128906)

    24c84d8
  12. miss-islington
    added a commit that references this issue on Jan 22, 2025

    pythongh-128770: fix ResourceWarning in test_pyrepl (pythonGH-128906)

    79bba48
  13. pablogsal
    added a commit that references this issue on Jan 22, 2025

    [3.13] gh-128770: fix ResourceWarning in test_pyrepl (GH-128906) (#12…

    67971cd
  14. hugovk
    added a commit that references this issue on Mar 27, 2025

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

    8a00c9a
  15. graingert
    added a commit that references this issue on Mar 27, 2025

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

    18dd42a
  16. hugovk
    added a commit that references this issue on Mar 29, 2025

    [3.13] gh-128770: raise warnings as errors in test suite - except for…

    07d4c7e
  17. diegorusso
    added a commit that references this issue on Apr 1, 2025

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

    b1996a3
  18. kulikjak commented on Apr 9, 2025

    @kulikjak
    kulikjak
    on Apr 9, 2025
    Contributor
    More actions

    Hi, after this change (specifically #131802), I am seeing the following errors when running test_peg_generator:

    ======================================================================
    ERROR: test_with_stmt_with_paren (test.test_peg_generator.test_c_parser.TestCParser.test_with_stmt_with_paren)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/build/Python-3.13.3/Lib/test/test_peg_generator/test_c_parser.py", line 113, in setUp
        cmd = support.missing_compiler_executable()
      File "/build/Python-3.13.3/Lib/test/support/__init__.py", line 1916, in missing_compiler_executable
        if spawn.find_executable(cmd[0]) is None:
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
      File "/usr/lib/python3.13/vendor-packages/setuptools/_distutils/spawn.py", line 87, in find_executable
        warnings.warn(
        ~~~~~~~~~~~~~^
            'Use shutil.which instead of find_executable', DeprecationWarning, stacklevel=2
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
    DeprecationWarning: Use shutil.which instead of find_executable

    I tried replacing spawn.find_executable with shutil.which as the warning suggests, but then I get a different distutils warning and test still fails:

    ======================================================================
    ERROR: test_with_stmt_with_paren (test.test_peg_generator.test_c_parser.TestCParser.test_with_stmt_with_paren)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/build/Python-3.13.3/Lib/test/test_peg_generator/test_c_parser.py", line 395, in test_with_stmt_with_paren
        self.run_test(grammar_source, test_source)
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/build/Python-3.13.3/Lib/test/test_peg_generator/test_c_parser.py", line 134, in run_test
        self.build_extension(grammar_source)
        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
      File "/build/Python-3.13.3/Lib/test/test_peg_generator/test_c_parser.py", line 131, in build_extension
        generate_parser_c_extension(grammar, Path('.'), library_dir=self.library_dir)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/build/Python-3.13.3/Tools/peg_generator/pegen/testutil.py", line 107, in generate_parser_c_extension
        compile_c_extension(
        ~~~~~~~~~~~~~~~~~~~^
            str(source),
            ^^^^^^^^^^^^
        ...<3 lines>...
            library_dir=library_dir,
            ^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/build/Python-3.13.3/Tools/peg_generator/pegen/build.py", line 98, in compile_c_extension
        from setuptools._distutils.dep_util import newer_group
      File "/usr/lib/python3.13/vendor-packages/setuptools/_distutils/dep_util.py", line 9, in __getattr__
        warnings.warn(
        ~~~~~~~~~~~~~^
            "dep_util is Deprecated. Use functions from setuptools instead.",
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            DeprecationWarning,
            ^^^^^^^^^^^^^^^^^^^
            stacklevel=2,
            ^^^^^^^^^^^^^
        )
        ^
    DeprecationWarning: dep_util is Deprecated. Use functions from setuptools instead.

    This is with 3.13 only, which makes sense as that is the only one which we have setuptools for also installed.

    I wonder what is different about my setup considering that nobody else reported this?

  19. nascheme
    added a commit that references this issue on Apr 9, 2025

    Call resetwarnings() in a few places.

    42d157b
  20. kulikjak commented on May 6, 2025

    @kulikjak
    kulikjak
    on May 6, 2025
    Contributor
    More actions

    FYI: both these issues were fixed recently in #132906 and #132921.

    I also encountered another issue uncovered by this change and created an issue for it here: #133509

  21. graingert commented on May 19, 2025

    @graingert
    graingert
    on May 19, 2025
    ContributorAuthor
    More actions

    this is in place now

    Reacted by Hugo van Kemenade
  22. graingert
    closed this as completedon May 19, 2025
  23. AmazerThaDik commented on May 19, 2025

    @AmazerThaDik
    AmazerThaDik
    on May 19, 2025 via email · Hidden as off-topic
    show commentMore actions
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 dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.