Skip to content

Add FutureWarning to deprecated_call() #11447

Closed
@chrimaho

Description

@chrimaho

What's the problem this feature will solve?

When implementing deprecated features, we are regularly expected to use the DeprecationWarning and PendingDeprecationWarning warnings. However, there is another one: FutureWarning. This particular warning is used by packages such as pydeprecate as the default warning for any functions that will be removed in the future.

However, when I write a function that raises the FutureWarning (or use the @deprecated decorator), then deprecated_call() currently does not catch the test successfully.

Describe the solution you'd like

I'd like to add FutureWarning to the list of warnings which are captured by deprecated_call().

This is the current behaviour:

from warnings import warn
from pytest import deprecated_call

def deprecated_func():
    warn("This function is deprecated", DeprecationWarning)
    pass

def future_deprecation_func():
    warn("This function will be deprecated in the future", FutureWarning)
    pass

def test_deprecated():
    """Expected to pass"""
    with deprecated_call():
        deprecated_func()

def test_futures():
    """Expected to fail"""
    with deprecated_call():
        future_deprecation_func()

The expected behaviour would be for both of these two test cases to pass successfully.

Alternative Solutions

N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions