Remove deprecated {FSCollector,Package}.{gethookproxy,isinitpath}

This commit is contained in:
Ran Benita 2024-01-01 13:10:56 +02:00
parent a53984a55b
commit f13724e2e3
3 changed files with 0 additions and 40 deletions

View File

@ -51,11 +51,6 @@ WARNING_CMDLINE_PREPARSE_HOOK = PytestRemovedIn8Warning(
"Please use pytest_load_initial_conftests hook instead."
)
FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestRemovedIn8Warning(
"The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated; "
"use self.session.gethookproxy() and self.session.isinitpath() instead. "
)
STRICT_OPTION = PytestRemovedIn8Warning(
"The --strict option is deprecated, use --strict-markers instead."
)

View File

@ -32,7 +32,6 @@ from _pytest.compat import LEGACY_PATH
from _pytest.config import Config
from _pytest.config import ConftestImportFailure
from _pytest.config.compat import _check_path
from _pytest.deprecated import FSCOLLECTOR_GETHOOKPROXY_ISINITPATH
from _pytest.deprecated import NODE_CTOR_FSPATH_ARG
from _pytest.mark.structures import Mark
from _pytest.mark.structures import MarkDecorator
@ -660,14 +659,6 @@ class FSCollector(Collector, abc.ABC):
"""The public constructor."""
return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
def gethookproxy(self, fspath: "os.PathLike[str]"):
warnings.warn(FSCOLLECTOR_GETHOOKPROXY_ISINITPATH, stacklevel=2)
return self.session.gethookproxy(fspath)
def isinitpath(self, path: Union[str, "os.PathLike[str]"]) -> bool:
warnings.warn(FSCOLLECTOR_GETHOOKPROXY_ISINITPATH, stacklevel=2)
return self.session.isinitpath(path)
class File(FSCollector, abc.ABC):
"""Base class for collecting tests from a file.

View File

@ -1,6 +1,5 @@
import re
import sys
import warnings
from pathlib import Path
import pytest
@ -68,31 +67,6 @@ def test_hookimpl_via_function_attributes_are_deprecated():
assert record.filename == __file__
def test_fscollector_gethookproxy_isinitpath(pytester: Pytester) -> None:
module = pytester.getmodulecol(
"""
def test_foo(): pass
""",
withinit=True,
)
assert isinstance(module, pytest.Module)
package = module.parent
assert isinstance(package, pytest.Package)
with pytest.warns(pytest.PytestDeprecationWarning, match="gethookproxy"):
package.gethookproxy(pytester.path)
with pytest.warns(pytest.PytestDeprecationWarning, match="isinitpath"):
package.isinitpath(pytester.path)
# The methods on Session are *not* deprecated.
session = module.session
with warnings.catch_warnings(record=True) as rec:
session.gethookproxy(pytester.path)
session.isinitpath(pytester.path)
assert len(rec) == 0
def test_strict_option_is_deprecated(pytester: Pytester) -> None:
"""--strict is a deprecated alias to --strict-markers (#7530)."""
pytester.makepyfile(