%global __python3 /usr/bin/python3.12 %global python3_pkgversion 3.12 %global pkgname pytest Name: python%{python3_pkgversion}-pytest %global base_version 7.4.2 #global prerelease ... Version: %{base_version}%{?prerelease:~%{prerelease}} Release: 1%{?dist} Summary: Simple powerful testing with Python License: MIT URL: https://pytest.org Source: %{pypi_source pytest %{base_version}%{?prerelease}} # see https://github.com/pytest-dev/pytest/issues/10042#issuecomment-1237132867 Patch: pytest-7.1.3-fix-xfails.patch # Remove -s from Python shebang, # ensure that packages installed with pip to user locations are testable # https://bugzilla.redhat.com/2152171 %undefine _py3_shebang_s # When building pytest for the first time with new Python version # we might not yet have all the BRs, those conditionals allow us to do that. # This can be used to disable all tests for faster bootstrapping. # The tests are enabled by default except when building on RHEL/ELN # (to avoid pulling in extra dependencies into next RHEL). %bcond_with tests # Only disabling the optional tests is a more complex but careful approach # Pytest will skip the related tests, so we only conditionalize the BRs %bcond_with optional_tests # To run the tests in %%check we use pytest-timeout # When building pytest for the first time with new Python version # that is not possible as it depends on pytest %bcond_with timeout # When building pytest for the first time with new Python version # we also don't have sphinx yet and cannot build docs. # The docs are enabled by default except when building on RHEL/ELN # (to avoid pulling in extra dependencies into next RHEL). %bcond_with docs BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-rpm-macros BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-pip # Those are also runtime deps, needed for tests # We keep them unconditionally, so we don't accidentally build pytest # before them and get broken dependencies BuildRequires: python%{python3_pkgversion}-packaging BuildRequires: python%{python3_pkgversion}-iniconfig BuildRequires: python%{python3_pkgversion}-pluggy >= 0.12 Requires: python%{python3_pkgversion}dist(packaging) Requires: python%{python3_pkgversion}dist(iniconfig) Requires: python%{python3_pkgversion}dist(pluggy) >= 0.12 %if %{with tests} # we avoid using %%pyproject_buildrequires -x testing as it mixes optional and non-optional deps BuildRequires: python%{python3_pkgversion}-attrs >= 19.2 BuildRequires: python%{python3_pkgversion}-hypothesis >= 3.56 BuildRequires: python%{python3_pkgversion}-pygments >= 2.7.2 BuildRequires: python%{python3_pkgversion}-xmlschema %if %{with optional_tests} BuildRequires: python%{python3_pkgversion}-argcomplete #BuildRequires: python%{python3_pkgversion}-asynctest -- not packaged in Fedora BuildRequires: python%{python3_pkgversion}-decorator BuildRequires: python%{python3_pkgversion}-jinja2 BuildRequires: python%{python3_pkgversion}-mock BuildRequires: python%{python3_pkgversion}-nose BuildRequires: python%{python3_pkgversion}-numpy BuildRequires: python%{python3_pkgversion}-pexpect BuildRequires: python%{python3_pkgversion}-pytest-xdist BuildRequires: python%{python3_pkgversion}-twisted BuildRequires: /usr/bin/lsof %endif %if %{with timeout} BuildRequires: python%{python3_pkgversion}-pytest-timeout %endif %endif BuildRequires: %{_bindir}/rst2html BuildArch: noarch %description The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. %prep %autosetup -p1 -n %{pkgname}-%{base_version}%{?prerelease} # Between 7.2.0 and 7.2.1 the tests were updated for pygments 2.14. # See https://github.com/pytest-dev/pytest/pull/10632 + 10637 (backport to 7.2). # To make the tests work with pygments 2.13, we set the added {endline}s to empty. # Once pygments 2.14+ is omnipresent, feel free to remove this hack, # but bump the minimal BuildRequired version of python3-pygments to 2.14. %if v"0%(%{python3} -c "import pygments; print(pygments.__version__)" 2>/dev/null)" < v"2.14~~" sed -i 's/"endline": "\\x1b\[90m\\x1b\[39;49;00m",/"endline": "",/' testing/conftest.py %endif # remove setuptools_scm dependency since we don't have it in RHEL sed -i '/setuptools-scm/d' setup.cfg # since setuptools_scm is not available we need to sed out it's usage from setup.py and set the correct version sed -i 's/setup()/setup(version="%{version}")/g' setup.py %build %py3_build for f in README CHANGELOG CONTRIBUTING ; do rst2html ${f}.rst > ${f}.html done %install %py3_install mv %{buildroot}%{_bindir}/pytest %{buildroot}%{_bindir}/pytest-%{python3_version} mv %{buildroot}%{_bindir}/py.test %{buildroot}%{_bindir}/py.test-%{python3_version} # remove shebangs from all scripts find %{buildroot}%{python3_sitelib} \ -name '*.py' \ -exec sed -i -e '1{/^#!/d}' {} \; %check %if %{with tests} %global __pytest %{buildroot}%{_bindir}/pytest # optional_tests deps contain pytest-xdist, so we can use it to run tests faster %pytest testing %{?with_timeout:--timeout=30} %{?with_optional_tests:-n auto} -rs %endif %files -n python%{python3_pkgversion}-%{pkgname} %doc CHANGELOG.html %doc README.html %doc CONTRIBUTING.html %license LICENSE %{_bindir}/pytest-%{python3_version} %{_bindir}/py.test-%{python3_version} %{python3_sitelib}/pytest-*.egg-info/ %{python3_sitelib}/_pytest/ %{python3_sitelib}/pytest/ %pycached %{python3_sitelib}/py.py %changelog * Thu Oct 19 2023 Tomáš Hrnčiar - 7.4.2-1 - Initial package - Fedora contributions by: Charalampos Stratakis David Malcolm Dennis Gilmore Gwyn Ciesla Igor Gnatenko Lumir Balhar Maxwell G Miro Hrončok Nils Philippsen Orion Poplawski Peter Robinson Petr Viktorin Richard Shaw Robert Kuska Stephen Gallagher Thomas Moschny Tomáš Hrnčiar