Expose the environment variables used by %pytest via %{py3_test_envvars}

This way, we will be able to reuse them in %tox from pyproject-rpm-macros.
Packagers will be able to use them in their spec files.

See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/A3QQSHP5OSLIVMCL52AR2GRBRXYQHU6B/

...

This is a backport of b647925300 sans 86c391c493 which sets PYTEST_XDIST_AUTO_NUM_WORKERS.
This commit is contained in:
Miro Hrončok 2022-10-24 17:47:59 +02:00 committed by Maxwell G
commit ab39941027
No known key found for this signature in database
GPG key ID: F79E4E25E8C661F8
4 changed files with 43 additions and 6 deletions

View file

@ -105,12 +105,15 @@
end
}
# This is intended for Python 3 only, hence also no Python version in the name.
%__pytest /usr/bin/pytest%(test %{python3_pkgversion} == 3 || echo -%{python3_version})
%pytest %{expand:\\\
# Environment variables used by %%pytest, %%tox or standalone, e.g.:
# %%{py3_test_envvars} %%{python3} -m unittest
%py3_test_envvars %{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_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}\\\
%__pytest}
%{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}}
# This is intended for Python 3 only, hence also no Python version in the name.
%__pytest /usr/bin/pytest%(test %{python3_pkgversion} == 3 || echo -%{python3_version})
%pytest %py3_test_envvars %__pytest