Skip to content

Commit d78eaac

Browse files
committed
Fix test
(cherry picked from commit eba1d70)
1 parent 0408218 commit d78eaac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/test_hooks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ def test_item_collection_does_not_break_on_non_function_items(testdir):
5252
5353
@pytest.mark.tryfirst
5454
def pytest_collection_modifyitems(session, config, items):
55-
items[:] = [CustomItem(name=item.name, parent=item.parent) for item in items]
55+
try:
56+
item_creator = CustomItem.from_parent # Only available in pytest >= 5.4.0
57+
except AttributeError:
58+
item_creator = CustomItem
59+
60+
items[:] = [item_creator(name=item.name, parent=item.parent) for item in items]
5661
5762
class CustomItem(pytest.Item):
5863
def runtest(self):

0 commit comments

Comments
 (0)