(cherry picked from commit eba1d70fcc)
This commit is contained in:
Alessio Bogon 2020-09-05 19:28:21 +02:00
parent 0408218680
commit d78eaace80
1 changed files with 6 additions and 1 deletions

View File

@ -52,7 +52,12 @@ def test_item_collection_does_not_break_on_non_function_items(testdir):
@pytest.mark.tryfirst
def pytest_collection_modifyitems(session, config, items):
items[:] = [CustomItem(name=item.name, parent=item.parent) for item in items]
try:
item_creator = CustomItem.from_parent # Only available in pytest >= 5.4.0
except AttributeError:
item_creator = CustomItem
items[:] = [item_creator(name=item.name, parent=item.parent) for item in items]
class CustomItem(pytest.Item):
def runtest(self):