-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelogmight present some backward compatibility issues which should be carefully noted in the changelog
Milestone
Description
We are currently upgrading py.test from 2.7.1 to 2.8.3 . We have found a small inconsistency in pytest.deprecated_call() behaviour.
We have few tests which are calling deprecated methods in our codebase. And afterwards we have few tests which are checking that the methods are deprecated. Running that tests on 2.7.1 produce no issues. After switching to 2.8.3, we have found out that the tests which are using pytest.deprecated_call() started failing. Here is an example:
import warnings
import pytest
def deprecated_function():
warnings.warn("deprecated", DeprecationWarning)
def test_one():
deprecated_function()
def test_two():
pytest.deprecated_call(deprecated_function)When running it on 2.8.3, the following AssertionError is raised:
def test_two():
> pytest.deprecated_call(deprecated_function)
E AssertionError: <function deprecated_function at 0x10ac51a28> did not produce DeprecationWarning
On 2.7.1 it works fine.
Seems to be adding warnings.simplefilter('always') call before deprecated_function() call fixes the issue:
import warnings
import pytest
def deprecated_function():
warnings.warn("deprecated", DeprecationWarning)
def test_one():
warnings.simplefilter('always')
deprecated_function()
def test_two():
pytest.deprecated_call(deprecated_function)Could you please check this small issue?
Metadata
Metadata
Assignees
Labels
type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelogmight present some backward compatibility issues which should be carefully noted in the changelog