From e3d30f8ebf75da51f4ac09a6b197716420994b1f Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Dec 2018 18:24:02 -0200 Subject: [PATCH] Remove deprecated PyCollector.makeitem Fix #4535 --- changelog/4535.removal.rst | 1 + doc/en/deprecations.rst | 22 ++++++++++++---------- src/_pytest/deprecated.py | 3 --- src/_pytest/python.py | 4 ---- testing/deprecated_test.py | 20 -------------------- testing/python/collect.py | 2 +- 6 files changed, 14 insertions(+), 38 deletions(-) create mode 100644 changelog/4535.removal.rst diff --git a/changelog/4535.removal.rst b/changelog/4535.removal.rst new file mode 100644 index 000000000..f89900587 --- /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 ca72bfbff..3ee5ca0d4 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 0d3dc85cc..30173e6b1 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -87,9 +87,6 @@ RECORD_XML_PROPERTY = RemovedInPytest4Warning( '"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 3db36fb19..a872a86ed 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -378,10 +378,6 @@ class PyCollector(PyobjMixin, nodes.Collector): 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 d54c868f2..111ff629f 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -268,26 +268,6 @@ def test_call_fixture_function_deprecated(): 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 2e534a259..53b3bc18b 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -808,7 +808,7 @@ class TestConftestCustomization(object): 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