Reintroduce warnings postponed in 6.0 (#7637)

This commit is contained in:
Maximilian Cosmo Sitter 2020-08-22 16:17:50 +02:00 committed by GitHub
parent d69abff2c7
commit 75af2bfa06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 16 deletions

View File

@ -0,0 +1 @@
Deprecate the ``pytest.collect`` module: all its names can be imported from ``pytest`` directly.

View File

@ -0,0 +1,6 @@
The ``pytest._fillfuncargs`` function is now deprecated. This function was kept
for backward compatibility with an older plugin.
It's functionality is not meant to be used directly, but if you must replace
it, use `function._request._fillfixtures()` instead, though note this is not
a public API and may break in the future.

View File

@ -0,0 +1,5 @@
The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
instead.
The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue
if you use this and want a replacement.

View File

@ -0,0 +1 @@
The :func:`pytest_warning_captured` hook has been deprecated in favor of :func:`pytest_warning_recorded`, and will be removed in a future version.

View File

@ -2,6 +2,7 @@ import functools
import inspect
import os
import sys
import warnings
from collections import defaultdict
from collections import deque
from types import TracebackType
@ -45,6 +46,7 @@ from _pytest.compat import TYPE_CHECKING
from _pytest.config import _PluggyPlugin
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from _pytest.deprecated import FILLFUNCARGS
from _pytest.mark import ParameterSet
from _pytest.outcomes import fail
from _pytest.outcomes import TEST_OUTCOME
@ -359,8 +361,7 @@ def reorder_items_atscope(
def fillfixtures(function: "Function") -> None:
"""Fill missing funcargs for a test function."""
# Uncomment this after 6.0 release (#7361)
# warnings.warn(FILLFUNCARGS, stacklevel=2)
warnings.warn(FILLFUNCARGS, stacklevel=2)
try:
request = function._request
except AttributeError:

View File

@ -13,6 +13,7 @@ import py.path
from pluggy import HookspecMarker
from _pytest.compat import TYPE_CHECKING
from _pytest.deprecated import WARNING_CAPTURED_HOOK
if TYPE_CHECKING:
import pdb
@ -723,9 +724,7 @@ def pytest_terminal_summary(
"""
# Uncomment this after 6.0 release (#7361)
# @hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK)
@hookspec(historic=True)
@hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK)
def pytest_warning_captured(
warning_message: "warnings.WarningMessage",
when: "Literal['config', 'collect', 'runtest']",

View File

@ -1,5 +1,6 @@
"""Generic mechanism for marking and selecting python functions."""
import typing
import warnings
from typing import AbstractSet
from typing import List
from typing import Optional
@ -22,6 +23,8 @@ from _pytest.config import ExitCode
from _pytest.config import hookimpl
from _pytest.config import UsageError
from _pytest.config.argparsing import Parser
from _pytest.deprecated import MINUS_K_COLON
from _pytest.deprecated import MINUS_K_DASH
from _pytest.store import StoreKey
if TYPE_CHECKING:
@ -185,14 +188,12 @@ def deselect_by_keyword(items: "List[Item]", config: Config) -> None:
if keywordexpr.startswith("-"):
# To be removed in pytest 7.0.0.
# Uncomment this after 6.0 release (#7361)
# warnings.warn(MINUS_K_DASH, stacklevel=2)
warnings.warn(MINUS_K_DASH, stacklevel=2)
keywordexpr = "not " + keywordexpr[1:]
selectuntil = False
if keywordexpr[-1:] == ":":
# To be removed in pytest 7.0.0.
# Uncomment this after 6.0 release (#7361)
# warnings.warn(MINUS_K_COLON, stacklevel=2)
warnings.warn(MINUS_K_COLON, stacklevel=2)
selectuntil = True
keywordexpr = keywordexpr[:-1]

View File

@ -1,10 +1,11 @@
import sys
import warnings
from types import ModuleType
from typing import Any
from typing import List
import pytest
from _pytest.deprecated import PYTEST_COLLECT_MODULE
COLLECT_FAKEMODULE_ATTRIBUTES = [
"Collector",
@ -31,8 +32,7 @@ class FakeCollectModule(ModuleType):
def __getattr__(self, name: str) -> Any:
if name not in self.__all__:
raise AttributeError(name)
# Uncomment this after 6.0 release (#7361)
# warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2)
warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2)
return getattr(pytest, name)

View File

@ -6,7 +6,6 @@ from _pytest import deprecated
from _pytest.pytester import Testdir
@pytest.mark.skip(reason="should be reintroduced in 6.1: #7361")
@pytest.mark.parametrize("attribute", pytest.collect.__all__) # type: ignore
# false positive due to dynamic attribute
def test_pytest_collect_module_deprecated(attribute):
@ -24,7 +23,6 @@ def test_external_plugins_integrated(testdir, plugin):
testdir.parseconfig("-p", plugin)
@pytest.mark.skip(reason="should be reintroduced in 6.1: #7361")
def test_fillfuncargs_is_deprecated() -> None:
with pytest.warns(
pytest.PytestDeprecationWarning,
@ -33,7 +31,6 @@ def test_fillfuncargs_is_deprecated() -> None:
pytest._fillfuncargs(mock.Mock())
@pytest.mark.skip(reason="should be reintroduced in 6.1: #7361")
def test_minus_k_dash_is_deprecated(testdir) -> None:
threepass = testdir.makepyfile(
test_threepass="""
@ -46,7 +43,6 @@ def test_minus_k_dash_is_deprecated(testdir) -> None:
result.stdout.fnmatch_lines(["*The `-k '-expr'` syntax*deprecated*"])
@pytest.mark.skip(reason="should be reintroduced in 6.1: #7361")
def test_minus_k_colon_is_deprecated(testdir) -> None:
threepass = testdir.makepyfile(
test_threepass="""