Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PyCollector.makeitem #4531

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/4535.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago.
22 changes: 12 additions & 10 deletions doc/en/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down Expand Up @@ -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
~~~~~~~~~~~~~~~~

Expand Down
3 changes: 0 additions & 3 deletions src/_pytest/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
4 changes: 0 additions & 4 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 0 additions & 20 deletions testing/deprecated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion testing/python/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down