diff --git a/changelog/4535.removal.rst b/changelog/4535.removal.rst new file mode 100644 index 00000000000..f899005871a --- /dev/null +++ b/changelog/4535.removal.rst @@ -0,0 +1 @@ +Removed deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index ca72bfbfff7..3ee5ca0d4f9 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -58,17 +58,7 @@ Becomes: exec("assert(1, 2)") # exec is used to avoid a top-level warning -Using ``Class`` in custom Collectors -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. deprecated:: 3.9 - -Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector`` -subclasses has been deprecated. Users instead should use ``pytest_pycollect_makeitem`` to customize node types during -collection. - -This issue should affect only advanced plugins who create new collection types, so if you see this warning -message please contact the authors so they can change the code. ``Config.warn`` and ``Node.warn`` @@ -280,6 +270,18 @@ Removed Features As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after an appropriate period of deprecation has passed. +Using ``Class`` in custom Collectors +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*Removed in version 4.0.* + +Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector`` +subclasses has been deprecated. Users instead should use ``pytest_pycollect_makeitem`` to customize node types during +collection. + +This issue should affect only advanced plugins who create new collection types, so if you see this warning +message please contact the authors so they can change the code. + Metafunc.addcall ~~~~~~~~~~~~~~~~ diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 0d3dc85cc62..30173e6b120 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -87,9 +87,6 @@ '"record_xml_property" is now deprecated.' ) -COLLECTOR_MAKEITEM = RemovedInPytest4Warning( - "pycollector makeitem was removed as it is an accidentially leaked internal api" -) PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST = RemovedInPytest4Warning( "Defining pytest_plugins in a non-top-level conftest is deprecated, " diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 3db36fb1982..a872a86ede5 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -378,10 +378,6 @@ def collect(self): values.sort(key=lambda item: item.reportinfo()[:2]) return values - def makeitem(self, name, obj): - warnings.warn(deprecated.COLLECTOR_MAKEITEM, stacklevel=2) - self._makeitem(name, obj) - def _makeitem(self, name, obj): # assert self.ihook.fspath == self.fspath, self return self.ihook.pytest_pycollect_makeitem(collector=self, name=name, obj=obj) diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index d54c868f290..111ff629f25 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -268,26 +268,6 @@ def fix(): assert fix() == 1 -def test_pycollector_makeitem_is_deprecated(): - from _pytest.python import PyCollector - from _pytest.warning_types import RemovedInPytest4Warning - - class PyCollectorMock(PyCollector): - """evil hack""" - - def __init__(self): - self.called = False - - def _makeitem(self, *k): - """hack to disable the actual behaviour""" - self.called = True - - collector = PyCollectorMock() - with pytest.warns(RemovedInPytest4Warning): - collector.makeitem("foo", "bar") - assert collector.called - - def test_fixture_named_request(testdir): testdir.copy_example() result = testdir.runpytest() diff --git a/testing/python/collect.py b/testing/python/collect.py index 2e534a25943..53b3bc18b04 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -808,7 +808,7 @@ def test_makeitem_non_underscore(self, testdir, monkeypatch): modcol = testdir.getmodulecol("def _hello(): pass") values = [] monkeypatch.setattr( - pytest.Module, "makeitem", lambda self, name, obj: values.append(name) + pytest.Module, "_makeitem", lambda self, name, obj: values.append(name) ) values = modcol.collect() assert "_hello" not in values