diff --git a/macros.python3 b/macros.python3 index 9d61547..7c3b26c 100644 --- a/macros.python3 +++ b/macros.python3 @@ -53,3 +53,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 239c390..cc09edd 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -82,6 +82,7 @@ install -m 644 %{SOURCE5} \ %changelog * Wed May 20 2020 Miro Hrončok - 3-56 - Implement %%py_provides +- Implement %%pytest * Tue Apr 28 2020 Miro Hrončok - 3-55 - Make pythonX-rpm-macros depend on python-rpm-macros (#1827811) diff --git a/tests/test_evals.py b/tests/test_evals.py index 8547c73..9e80d29 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -81,3 +81,13 @@ def test_py_provides_with_evr(): assert 'Provides: python3-foo = 123' in lines assert 'Provides: python-foo = 123' in lines assert len(lines) == 2 + + +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]