#55 Implement %pytest
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/python-rpm-macros pytest  into  master

file modified
+9
@@ -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}

file modified
+4 -1
@@ -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 @@ 

  

  

  %changelog

+ * Mon May 11 2020 Miro Hrončok <mhroncok@redhat.com> - 3.8-8

+ - Implement %%pytest

+ 

  * Thu May 07 2020 Miro Hrončok <mhroncok@redhat.com> - 3.8-7

  - Change %%__default_python3_pkgversion from 38 to 3.8

  

file modified
+10
@@ -122,3 +122,13 @@ 

      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]