forked from pool/python-SQLAlchemy
(gh#sqlalchemy/sqlalchemy#5635) OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-SQLAlchemy?expand=0&rev=174
61 lines
2.5 KiB
Diff
61 lines
2.5 KiB
Diff
--- a/lib/sqlalchemy/testing/plugin/pytestplugin.py
|
|
+++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py
|
|
@@ -162,16 +162,19 @@ def pytest_collection_modifyitems(sessio
|
|
if sub_cls is not test_class.cls:
|
|
per_cls_dict = rebuilt_items[test_class.cls]
|
|
|
|
- # in pytest 5.4.0
|
|
- # for inst in pytest.Class.from_parent(
|
|
- # test_class.parent.parent, name=sub_cls.__name__
|
|
- # ).collect():
|
|
-
|
|
- for inst in pytest.Class(
|
|
- sub_cls.__name__, parent=test_class.parent.parent
|
|
- ).collect():
|
|
- for t in inst.collect():
|
|
- per_cls_dict[t.name].append(t)
|
|
+ if hasattr(pytest.Class, "from_parent"):
|
|
+ # in pytest 5.4.0
|
|
+ for inst in pytest.Class.from_parent(
|
|
+ test_class.parent.parent, name=sub_cls.__name__
|
|
+ ).collect():
|
|
+ for t in inst.collect():
|
|
+ per_cls_dict[t.name].append(t)
|
|
+ else:
|
|
+ for inst in pytest.Class(
|
|
+ sub_cls.__name__, parent=test_class.parent.parent
|
|
+ ).collect():
|
|
+ for t in inst.collect():
|
|
+ per_cls_dict[t.name].append(t)
|
|
|
|
newitems = []
|
|
for item in items:
|
|
@@ -197,16 +200,17 @@ def pytest_pycollect_makeitem(collector,
|
|
if inspect.isclass(obj) and plugin_base.want_class(name, obj):
|
|
|
|
# in pytest 5.4.0
|
|
- # return [
|
|
- # pytest.Class.from_parent(collector,
|
|
- # name=parametrize_cls.__name__)
|
|
- # for parametrize_cls in _parametrize_cls(collector.module, obj)
|
|
- # ]
|
|
-
|
|
- return [
|
|
- pytest.Class(parametrize_cls.__name__, parent=collector)
|
|
- for parametrize_cls in _parametrize_cls(collector.module, obj)
|
|
- ]
|
|
+ if hasattr(pytest.Class, "from_parent"):
|
|
+ return [
|
|
+ pytest.Class.from_parent(collector,
|
|
+ name=parametrize_cls.__name__)
|
|
+ for parametrize_cls in _parametrize_cls(collector.module, obj)
|
|
+ ]
|
|
+ else:
|
|
+ return [
|
|
+ pytest.Class(parametrize_cls.__name__, parent=collector)
|
|
+ for parametrize_cls in _parametrize_cls(collector.module, obj)
|
|
+ ]
|
|
elif (
|
|
inspect.isfunction(obj)
|
|
and isinstance(collector, pytest.Instance)
|