Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab39941027 |
4 changed files with 43 additions and 6 deletions
|
|
@ -131,6 +131,15 @@
|
|||
end
|
||||
}
|
||||
|
||||
# Environment variables for testing used standalone, e.g.:
|
||||
# %%{py_test_envvars} %%{python} -m unittest
|
||||
%py_test_envvars %{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
||||
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\
|
||||
PYTHONDONTWRITEBYTECODE=1\\\
|
||||
%{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}}
|
||||
|
||||
%python_disable_dependency_generator() \
|
||||
%undefine __pythondist_requires \
|
||||
%{nil}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ elseif posix.stat('macros.python-srpm') then
|
|||
end
|
||||
}
|
||||
Version: %{__default_python3_version}
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?dist}
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
|
|
@ -159,6 +159,9 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
|
|||
|
||||
|
||||
%changelog
|
||||
* Sun Nov 13 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-6
|
||||
- Expose the environment variables used by %%pytest via %%{py3_test_envvars}
|
||||
|
||||
* Tue Oct 25 2022 Lumír Balhar <lbalhar@redhat.com> - 3.11-5
|
||||
- Include pathfix.py in this package
|
||||
|
||||
|
|
|
|||
|
|
@ -352,6 +352,27 @@ def test_pytest_addopts_preserves_envvar(__pytest_addopts):
|
|||
assert 'z--' not in echoed
|
||||
|
||||
|
||||
@pytest.mark.parametrize('__pytest_addopts', ['-X', None])
|
||||
def test_py3_test_envvars(lib, __pytest_addopts):
|
||||
lines = rpm_eval('%{py3_test_envvars}\\\n%{python3} -m unittest',
|
||||
buildroot='BUILDROOT',
|
||||
_smp_build_ncpus='3',
|
||||
__pytest_addopts=__pytest_addopts)
|
||||
assert all(l.endswith('\\') for l in lines[:-1])
|
||||
stripped_lines = [l.strip(' \\') for l in lines]
|
||||
sitearch = f'BUILDROOT/usr/{lib}/python{X_Y}/site-packages'
|
||||
sitelib = f'BUILDROOT/usr/lib/python{X_Y}/site-packages'
|
||||
assert f'PYTHONPATH="${{PYTHONPATH:-{sitearch}:{sitelib}}}"' in stripped_lines
|
||||
assert 'PATH="BUILDROOT/usr/bin:$PATH"' in stripped_lines
|
||||
assert 'CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"' in stripped_lines
|
||||
assert 'PYTHONDONTWRITEBYTECODE=1' in stripped_lines
|
||||
if __pytest_addopts:
|
||||
assert f'PYTEST_ADDOPTS="${{PYTEST_ADDOPTS:-}} {__pytest_addopts}"' in stripped_lines
|
||||
else:
|
||||
assert 'PYTEST_ADDOPTS' not in ''.join(lines)
|
||||
assert stripped_lines[-1] == '/usr/bin/python3 -m unittest'
|
||||
|
||||
|
||||
def test_pypi_source_default_name():
|
||||
urls = rpm_eval('%pypi_source',
|
||||
name='foo', version='6')
|
||||
|
|
@ -686,6 +707,7 @@ unversioned_macros = pytest.mark.parametrize('macro', [
|
|||
'%py_install_egg',
|
||||
'%py_install_wheel',
|
||||
'%py_check_import',
|
||||
'%py_test_envvars',
|
||||
])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue