From 0d3f1e6b7457f57fa1e2d4c9976665574345fb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 6 May 2020 13:21:32 +0200 Subject: [PATCH] Implement %pytest See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/XLPDSH362PJKMJCAYOXNJNV53Y66EF6B/ --- macros.python3 | 9 +++++++++ python-rpm-macros.spec | 5 ++++- tests/test_evals.py | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/macros.python3 b/macros.python3 index 7af56f1..a093d0f 100644 --- a/macros.python3 +++ b/macros.python3 @@ -62,3 +62,12 @@ print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc") end } + +# This is intended for Python 3 only, hence also no Python version in the name. +%__pytest /usr/bin/pytest +%pytest %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + PATH="%{buildroot}%{_bindir}:$PATH"\\\ + PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ + PYTHONDONTWRITEBYTECODE=1\\\ + %__pytest} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index f10aafb..e4c9c67 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3.8 -Release: 7%{?dist} +Release: 8%{?dist} Summary: The common Python RPM macros # macros and lua: MIT, compileall2.py: PSFv2 @@ -107,6 +107,9 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/ %changelog +* Mon May 11 2020 Miro Hrončok - 3.8-8 +- Implement %%pytest + * Thu May 07 2020 Miro Hrončok - 3.8-7 - Change %%__default_python3_pkgversion from 38 to 3.8 diff --git a/tests/test_evals.py b/tests/test_evals.py index 055426b..89848ca 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -122,3 +122,13 @@ def test_py_provides_with_evr(): assert 'Provides: python-foo = 123' in lines assert f'Provides: python{X_Y}-foo = 123' in lines assert len(lines) == 3 + + +def test_pytest_passes_options_naturally(): + lines = rpm_eval('%pytest -k foo') + assert '/usr/bin/pytest -k foo' in lines[-1] + + +def test_pytest_different_command(): + lines = rpm_eval('%pytest', __pytest='pytest-3') + assert 'pytest-3' in lines[-1]