Remove `PytestRemovedIn7Warning`

Fix #8838.
This commit is contained in:
Ran Benita 2021-12-07 22:18:01 +02:00
parent 0f39f11d88
commit ee93557ef3
5 changed files with 19 additions and 14 deletions

View File

@ -0,0 +1,15 @@
As per our policy, the following features have been deprecated in the 6.X series and are now
removed:
* ``pytest._fillfuncargs`` function.
* ``pytest_warning_captured`` hook - use ``pytest_warning_recorded`` instead.
* ``-k -foobar`` syntax - use ``-k 'not foobar'`` instead.
* ``-k foobar:`` syntax.
* ``pytest.collect`` module - import from ``pytest`` directly.
For more information consult
`Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ in the docs.

View File

@ -48,13 +48,6 @@ class PytestDeprecationWarning(PytestWarning, DeprecationWarning):
__module__ = "pytest" __module__ = "pytest"
@final
class PytestRemovedIn7Warning(PytestDeprecationWarning):
"""Warning class for features that will be removed in pytest 7."""
__module__ = "pytest"
@final @final
class PytestRemovedIn8Warning(PytestDeprecationWarning): class PytestRemovedIn8Warning(PytestDeprecationWarning):
"""Warning class for features that will be removed in pytest 8.""" """Warning class for features that will be removed in pytest 8."""

View File

@ -49,8 +49,6 @@ def catch_warnings_for_item(
warnings.filterwarnings("always", category=DeprecationWarning) warnings.filterwarnings("always", category=DeprecationWarning)
warnings.filterwarnings("always", category=PendingDeprecationWarning) warnings.filterwarnings("always", category=PendingDeprecationWarning)
warnings.filterwarnings("error", category=pytest.PytestRemovedIn7Warning)
apply_warning_filters(config_filters, cmdline_filters) apply_warning_filters(config_filters, cmdline_filters)
# apply filters from "filterwarnings" marks # apply filters from "filterwarnings" marks

View File

@ -66,7 +66,6 @@ from _pytest.warning_types import PytestCollectionWarning
from _pytest.warning_types import PytestConfigWarning from _pytest.warning_types import PytestConfigWarning
from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import PytestDeprecationWarning
from _pytest.warning_types import PytestExperimentalApiWarning from _pytest.warning_types import PytestExperimentalApiWarning
from _pytest.warning_types import PytestRemovedIn7Warning
from _pytest.warning_types import PytestRemovedIn8Warning from _pytest.warning_types import PytestRemovedIn8Warning
from _pytest.warning_types import PytestUnhandledCoroutineWarning from _pytest.warning_types import PytestUnhandledCoroutineWarning
from _pytest.warning_types import PytestUnhandledThreadExceptionWarning from _pytest.warning_types import PytestUnhandledThreadExceptionWarning
@ -125,7 +124,6 @@ __all__ = [
"PytestConfigWarning", "PytestConfigWarning",
"PytestDeprecationWarning", "PytestDeprecationWarning",
"PytestExperimentalApiWarning", "PytestExperimentalApiWarning",
"PytestRemovedIn7Warning",
"PytestRemovedIn8Warning", "PytestRemovedIn8Warning",
"Pytester", "Pytester",
"PytestPluginManager", "PytestPluginManager",

View File

@ -517,6 +517,7 @@ class TestDeprecationWarningsByDefault:
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str() assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
@pytest.mark.skip("not relevant until pytest 8.0")
@pytest.mark.parametrize("change_default", [None, "ini", "cmdline"]) @pytest.mark.parametrize("change_default", [None, "ini", "cmdline"])
def test_removed_in_x_warning_as_error(pytester: Pytester, change_default) -> None: def test_removed_in_x_warning_as_error(pytester: Pytester, change_default) -> None:
"""This ensures that PytestRemovedInXWarnings raised by pytest are turned into errors. """This ensures that PytestRemovedInXWarnings raised by pytest are turned into errors.
@ -528,7 +529,7 @@ def test_removed_in_x_warning_as_error(pytester: Pytester, change_default) -> No
""" """
import warnings, pytest import warnings, pytest
def test(): def test():
warnings.warn(pytest.PytestRemovedIn7Warning("some warning")) warnings.warn(pytest.PytestRemovedIn8Warning("some warning"))
""" """
) )
if change_default == "ini": if change_default == "ini":
@ -536,12 +537,12 @@ def test_removed_in_x_warning_as_error(pytester: Pytester, change_default) -> No
""" """
[pytest] [pytest]
filterwarnings = filterwarnings =
ignore::pytest.PytestRemovedIn7Warning ignore::pytest.PytestRemovedIn8Warning
""" """
) )
args = ( args = (
("-Wignore::pytest.PytestRemovedIn7Warning",) ("-Wignore::pytest.PytestRemovedIn8Warning",)
if change_default == "cmdline" if change_default == "cmdline"
else () else ()
) )