Compare commits

...

1 Commits
main ... 1.1

3 changed files with 8 additions and 89 deletions

View File

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

View File

@ -1,66 +0,0 @@
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)