- Switch to autosetup and pyproject macros.

- Add numpy to BuildRequires, needed for the testsuite.
- No more greedy globs in %files.
- Add patch support-pytest-8.patch:
  * Support pytest >= 8 changes.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-lazy-fixture?expand=0&rev=11
This commit is contained in:
Steve Kowalik 2024-05-06 06:00:55 +00:00 committed by Git OBS Bridge
parent 0a931122c8
commit c923e61001
3 changed files with 89 additions and 8 deletions

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Mon May 6 05:59:39 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Switch to autosetup and pyproject macros.
- Add numpy to BuildRequires, needed for the testsuite.
- No more greedy globs in %files.
- Add patch support-pytest-8.patch:
* Support pytest >= 8 changes.
-------------------------------------------------------------------
Fri Apr 21 12:31:46 UTC 2023 - Dirk Müller <dmueller@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-pytest-lazy-fixture
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,7 +16,6 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%{?sle15_python_module_pythons}
Name: python-pytest-lazy-fixture
Version: 0.6.3
@ -25,11 +24,16 @@ Summary: Helper to use fixtures in pytest.markparametrize
License: MIT
URL: https://github.com/tvorog/pytest-lazy-fixture
Source: https://files.pythonhosted.org/packages/source/p/pytest-lazy-fixture/pytest-lazy-fixture-%{version}.tar.gz
BuildRequires: %{python_module pytest >= 3.2.5}
# PATCH-FIX-UPSTREAM (ish) Sourced from gh#TvoroG/pytest-lazy-fixture/issues/65
Patch0: support-pytest-8.patch
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest >= 8.0}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-pytest >= 3.2.5
Requires: python-pytest >= 8.0
BuildArch: noarch
%python_subpackages
@ -37,13 +41,13 @@ BuildArch: noarch
Helper to use fixtures in pytest.mark.parametrize.
%prep
%setup -q -n pytest-lazy-fixture-%{version}
%autosetup -p1 -n pytest-lazy-fixture-%{version}
%build
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
@ -52,6 +56,8 @@ Helper to use fixtures in pytest.mark.parametrize.
%files %{python_files}
%license LICENSE
%doc README.rst
%{python_sitelib}/*
%{python_sitelib}/pytest_lazyfixture.py
%pycache_only %{python_sitelib}/__pycache__/pytest_lazyfixture*.pyc
%{python_sitelib}/pytest_lazy_fixture-%{version}.dist-info
%changelog

66
support-pytest-8.patch Normal file
View File

@ -0,0 +1,66 @@
diff --git a/pytest_lazyfixture.py b/pytest_lazyfixture.py
index abf5db5..df83ce7 100644
--- a/pytest_lazyfixture.py
+++ b/pytest_lazyfixture.py
@@ -71,14 +71,13 @@ def pytest_make_parametrize_id(config, val, argname):
def pytest_generate_tests(metafunc):
yield
- normalize_metafunc_calls(metafunc, 'funcargs')
- normalize_metafunc_calls(metafunc, 'params')
+ normalize_metafunc_calls(metafunc)
-def normalize_metafunc_calls(metafunc, valtype, used_keys=None):
+def normalize_metafunc_calls(metafunc, used_keys=None):
newcalls = []
for callspec in metafunc._calls:
- calls = normalize_call(callspec, metafunc, valtype, used_keys)
+ calls = normalize_call(callspec, metafunc, used_keys)
newcalls.extend(calls)
metafunc._calls = newcalls
@@ -98,17 +97,21 @@ def copy_metafunc(metafunc):
return copied
-def normalize_call(callspec, metafunc, valtype, used_keys):
+def normalize_call(callspec, metafunc, used_keys):
fm = metafunc.config.pluginmanager.get_plugin('funcmanage')
used_keys = used_keys or set()
- valtype_keys = set(getattr(callspec, valtype).keys()) - used_keys
+ keys = set(callspec.params.keys()) - used_keys
+ print(used_keys, keys)
- for arg in valtype_keys:
- val = getattr(callspec, valtype)[arg]
+ for arg in keys:
+ val = callspec.params[arg]
if is_lazy_fixture(val):
try:
- _, fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], metafunc.definition.parent)
+ if pytest.version_tuple >= (8, 0, 0):
+ fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure(metafunc.definition.parent, [val.name], {})
+ else:
+ _, fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], metafunc.definition.parent)
except ValueError:
# 3.6.0 <= pytest < 3.7.0; `FixtureManager.getfixtureclosure` returns 2 values
fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], metafunc.definition.parent)
@@ -117,14 +120,14 @@ def normalize_call(callspec, metafunc, valtype, used_keys):
fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], current_node)
extra_fixturenames = [fname for fname in fixturenames_closure
- if fname not in callspec.params and fname not in callspec.funcargs]
+ if fname not in callspec.params]# and fname not in callspec.funcargs]
newmetafunc = copy_metafunc(metafunc)
newmetafunc.fixturenames = extra_fixturenames
newmetafunc._arg2fixturedefs.update(arg2fixturedefs)
newmetafunc._calls = [callspec]
fm.pytest_generate_tests(newmetafunc)
- normalize_metafunc_calls(newmetafunc, valtype, used_keys | set([arg]))
+ normalize_metafunc_calls(newmetafunc, used_keys | set([arg]))
return newmetafunc._calls
used_keys.add(arg)