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 — warnings: warning filters set by collected code during collection have no effect during test run · Issue #13485 · pytest-dev/pytest

warnings: warning filters set by collected code during collection have no effect during test run #13485

New issue
Copy link
New issue
Copy link
Open
Bug
#15129
Open
warnings: warning filters set by collected code during collection have no effect during test run#13485
Bug
#15129
Copy link
Assignees
RonnyPfannschmidt
Labels
plugin: warningsrelated to the warnings builtin plugintype: bugproblem that needs to be addressedtype: selftestsa problem in the tests of pytest

Description

@bluetech
bluetech
opened on Jun 3, 2025
Issue body actions

In 2017 there was an issue #2430 complaining that module-level calls to warnings.filterwarnings are getting reset by pytest and thus have no effect. PR #2445 added a fix for this and a test testing/test_warnings.py::test_works_with_filterwarnings (still present).

In 2018 there was a change to add warning capture during collection 1a9d913. This means collection is now wrapped in a with warnings.catch_warnings and so all warnings.filterwarnings get reset after collection, regressing the issue #2430.

The tests continued to pass due to how it was written, however running pytest with -Wdefault causes it to (correctly) fail (see #13480).

Since we haven't received any complaints since it regressed, and a fix I think would be difficult, IMO we should just delete the test, basically WONTFIXing #2430.

Activity

  1. bluetech
    added
    type: bugproblem that needs to be addressed
    plugin: warningsrelated to the warnings builtin plugin
    type: selftestsa problem in the tests of pytest
    on Jun 3, 2025
  2. bluetech
    added the
    Bug
    issue type on Jun 3, 2025
  3. dfremont commented on Jul 25, 2025

    @dfremont
    dfremont
    on Jul 25, 2025
    More actions

    Since we haven't received any complaints since it regressed, and a fix I think would be difficult, IMO we should just delete the test, basically WONTFIXing #2430.

    I would like to submit a complaint :) We set a warning filter in one of our modules to suppress warnings from a 3rd-party library (scipy), and it's quite annoying that the warnings still show up when we run our test suite. When I first looked into this a couple of years ago, I saw #2430 was closed, so I assumed there was something specific to our setup causing the problem. But I've been revisiting it recently, and I think the problem is indeed caused by the fix to #3251 that you mention above.

    (I'll mention that I'm actually hoping for scipy to add an option to not emit the warnings in question in the first place; if that happens, then this issue would no longer bother us. But of course it might come up again with some other 3rd-party library.)

  4. RonnyPfannschmidt commented on Jul 26, 2025

    @RonnyPfannschmidt
    RonnyPfannschmidt
    on Jul 26, 2025
    Member
    More actions

    i actually have multiple places where i need a fix for this as well (i currently simply have a function that installs filter and invoke them globally and in a staggering number of pytest hooks, i just missed this issue to add my complaint

  5. RonnyPfannschmidt
    self-assigned this
    on Jul 26, 2025
  6. theacodes commented on Oct 16, 2025

    @theacodes
    theacodes
    on Oct 16, 2025
    More actions

    I'd also like to chime in with a (friendly) "complaint", since I'd like to silence the warnings emitted due to shapely/shapely#2215, but pytest is gleefully ignoring my module-level filters. I can work around it, but I'd rather not have to. :)

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

Metadata

Metadata

Assignees

  • @RonnyPfannschmidt
    RonnyPfannschmidt

Labels

plugin: warningsrelated to the warnings builtin plugintype: bugproblem that needs to be addressedtype: selftestsa problem in the tests of pytest

Type

Bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — 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.