@@ -615,6 +615,43 @@ def test_incompatible_item():
615615 assert result .parseoutcomes ()["warnings" ] == 1
616616
617617
618+ def test_incompatible_test_item_2 (pytester ):
619+ pytester .makeconftest ("""
620+ import inspect
621+ import pytest
622+
623+ class CustomItem(pytest.Item):
624+ def __init__(self, name, parent=None, config=None, session=None, nodeid=None, function=None, **kwargs):
625+ super().__init__(name, parent, config, session, nodeid, **kwargs)
626+ self.function = function
627+ self.obj = None
628+
629+ def runtest(self):
630+ self.function()
631+
632+ @pytest.hookimpl(wrapper=True, trylast=True)
633+ def pytest_pycollect_makeitem(collector, name: str, obj: object):
634+ result = yield
635+ if not inspect.isfunction(obj):
636+ return result
637+ return CustomItem.from_parent(name=name, parent=collector, function=obj)
638+ """ )
639+
640+ pytester .makepyfile ("""
641+ import pytest
642+
643+ def test_incompatible_item():
644+ assert True
645+ """ )
646+ result = pytester .runpytest ("--parallel-threads=10" , "-v" , "-W" , "default" )
647+ result .stdout .fnmatch_lines (
648+ [
649+ "*::test_incompatible_item PASSED*" ,
650+ ]
651+ )
652+ assert result .parseoutcomes ()["warnings" ] == 1
653+
654+
618655def test_known_incompatible_test_item_doesnt_warn (pytester ):
619656 pytester .makeconftest ("""
620657 import inspect
0 commit comments