pytest-dev / pytest-dev/pytest

provide framework integration for warning filter setup

Open
#6,838 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: warnings type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

pytest overriding previously existing warnings setups creates troube when using warnings filters as a signaling mechanism

in a project i had a warnigns.simplefilter("error", FWExpiredDeprecationWarning)
which was ignored under pytest

as a crude workaround i created

import warnings
from fw.deprecations import install_filter

from pytest import hookimpl


@hookimpl(tryfirst=True)
def pytest_runtest_protocol():
	install_filter()


pytest_collection = pytest_runtest_protocol

to trigger the warnings at least in some cases

it would e nice if pytest provided a general hook to setup own filters in the warning filter setup

pytest_setup_warningfilter(...) might be a nice addition

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating pytest's warning-filter setup and reviewing the issue's workaround, including install_filter and the proposed pytest_setup_warningfilter hook. Determine how an integration point could preserve project-defined filters during pytest runs. Done means the requested general hook is defined and documented with coverage for existing warning-filter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.