if sub_cls is not test_class.cls:
list_ = rebuilt_items[test_class.cls]
- for inst in pytest.Class(
- sub_cls.__name__,
+ ctor = getattr(pytest.Class, "from_parent", pytest.Class)
+ for inst in ctor(
+ name=sub_cls.__name__,
parent=test_class.parent.parent).collect():
list_.extend(inst.collect())
def pytest_pycollect_makeitem(collector, name, obj):
if inspect.isclass(obj) and plugin_base.want_class(obj):
- return pytest.Class(name, parent=collector)
+ ctor = getattr(pytest.Class, "from_parent", pytest.Class)
+ return ctor(name=name, parent=collector)
elif inspect.isfunction(obj) and \
isinstance(collector, pytest.Instance) and \
plugin_base.want_method(collector.cls, obj):