Skip to content

Commit

Permalink
Reintroduce warnings postponed in 6.0 (#7637)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsitter authored Aug 22, 2020
1 parent d69abff commit 75af2bf
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions changelog/6981.deprecation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate the ``pytest.collect`` module: all its names can be imported from ``pytest`` directly.
6 changes: 6 additions & 0 deletions changelog/7097.deprecation.rst
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions changelog/7210.deprecation.rst
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions changelog/7255.deprecation.rst
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 3 additions & 2 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import inspect
import os
import sys
import warnings
from collections import defaultdict
from collections import deque
from types import TracebackType
Expand Down Expand Up @@ -45,6 +46,7 @@
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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pluggy import HookspecMarker

from _pytest.compat import TYPE_CHECKING
from _pytest.deprecated import WARNING_CAPTURED_HOOK

if TYPE_CHECKING:
import pdb
Expand Down Expand Up @@ -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']",
Expand Down
9 changes: 5 additions & 4 deletions src/_pytest/mark/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,6 +23,8 @@
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:
Expand Down Expand Up @@ -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]

Expand Down
6 changes: 3 additions & 3 deletions src/pytest/collect.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -31,8 +32,7 @@ def __dir__(self) -> List[str]:
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)


Expand Down
4 changes: 0 additions & 4 deletions testing/deprecated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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):
Expand All @@ -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,
Expand All @@ -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="""
Expand All @@ -46,7 +43,6 @@ def test_three(): assert 1
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="""
Expand Down

0 comments on commit 75af2bf

Please sign in to comment.