From cf13b151ec42182ff3b9a57f0b642c8403c6df7e314145fa38cdc5fad26ce630 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 8 Oct 2020 15:45:35 +0000 Subject: [PATCH] - Add pytest_depr_from_parent.patch to fix FTBGS with pytest 6.* (gh#sqlalchemy/sqlalchemy#5635) OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-SQLAlchemy?expand=0&rev=174 --- pytest_depr_from_parent.patch | 60 +++++++++++++++++++++++++++++++++++ python-SQLAlchemy.changes | 6 ++++ python-SQLAlchemy.spec | 7 +++- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 pytest_depr_from_parent.patch diff --git a/pytest_depr_from_parent.patch b/pytest_depr_from_parent.patch new file mode 100644 index 0000000..8c9b30e --- /dev/null +++ b/pytest_depr_from_parent.patch @@ -0,0 +1,60 @@ +--- 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) diff --git a/python-SQLAlchemy.changes b/python-SQLAlchemy.changes index fe48d0d..2b60a07 100644 --- a/python-SQLAlchemy.changes +++ b/python-SQLAlchemy.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Oct 8 15:45:04 UTC 2020 - Matej Cepl + +- Add pytest_depr_from_parent.patch to fix FTBGS with pytest 6.* + (gh#sqlalchemy/sqlalchemy#5635) + ------------------------------------------------------------------- Thu Aug 20 12:00:42 UTC 2020 - Ondřej Súkup diff --git a/python-SQLAlchemy.spec b/python-SQLAlchemy.spec index d106e8f..1eadcb5 100644 --- a/python-SQLAlchemy.spec +++ b/python-SQLAlchemy.spec @@ -25,6 +25,9 @@ Summary: Database Abstraction Library License: MIT URL: https://www.sqlalchemy.org Source: https://files.pythonhosted.org/packages/source/S/SQLAlchemy/SQLAlchemy-%{version}.tar.gz +# PATCH-FIX-UPSTREAM pytest_depr_from_parent.patch gh#sqlalchemy/sqlalchemy#5635 mcepl@suse.com +# pytest >= 3.4.0 requires Class.from_parent call +Patch0: pytest_depr_from_parent.patch # devel is needed for optional C extensions cprocessors.so, cresultproxy.so and cutils.so BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} @@ -65,6 +68,8 @@ reference for python-SQLAlchemy. %prep %setup -q -n SQLAlchemy-%{version} +%autopatch -p1 + rm -rf doc/build # Remove unnecessary scripts for building documentation sed -i 's/\r$//' examples/dynamic_dict/dynamic_dict.py @@ -77,7 +82,7 @@ export CFLAGS="%{optflags} -fno-strict-aliasing" %python_expand %fdupes %{buildroot}%{$python_sitearch} %check -%pytest -n auto +%pytest_arch -n auto %files %{python_files} %license LICENSE