diff --git a/tests/printrun.spec b/tests/printrun.spec index 56a7de6..abca9e1 100644 --- a/tests/printrun.spec +++ b/tests/printrun.spec @@ -24,7 +24,7 @@ Building this tests that lang files are marked with %%lang in filelist. %generate_buildrequires -%pyproject_buildrequires +%pyproject_buildrequires -R %build diff --git a/tests/python-distroinfo.spec b/tests/python-distroinfo.spec index 52f8354..7303eca 100644 --- a/tests/python-distroinfo.spec +++ b/tests/python-distroinfo.spec @@ -28,6 +28,8 @@ Summary: %{summary} %prep %autosetup -p1 -n distroinfo-%{version} +# we don't need pytest-runner +sed -Ei "s/(, )?'pytest-runner'//" setup.py %generate_buildrequires diff --git a/tests/python-httpbin.spec b/tests/python-httpbin.spec index d93ba10..e1e25c6 100644 --- a/tests/python-httpbin.spec +++ b/tests/python-httpbin.spec @@ -10,6 +10,14 @@ BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros +# no flask, itsdangerous, raven, werkzeug packaged for EPEL 9 yet +# cannot run tests on EPEL and also cannot BuildRequire runtime deps +%if 0%{?fedora} +%bcond_without tests +%else +%bcond_with tests +%endif + %description This package buildrequires a package with extra: raven[flask]. @@ -34,7 +42,7 @@ sed -i /Content-Length/d test_httpbin.py sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1))/def no\1/' test_httpbin.py %generate_buildrequires -%pyproject_buildrequires -t +%pyproject_buildrequires %{?with_tests:-t}%{?!with_tests:-R} %build @@ -46,6 +54,7 @@ sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1 %pyproject_save_files httpbin +%if %{with tests} %check %tox @@ -53,6 +62,7 @@ sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1 # The runtime dependencies contain raven[flask], we assert we got them. # The %%tox above also dies without it, but this makes it more explicit %{python3} -c 'import blinker, flask' # transitive deps +%endif %files -n python3-httpbin -f %{pyproject_files} diff --git a/tests/python-openqa_client.spec b/tests/python-openqa_client.spec index 6e6dfbe..fdf903d 100644 --- a/tests/python-openqa_client.spec +++ b/tests/python-openqa_client.spec @@ -30,6 +30,10 @@ Summary: %{summary} # we sed it out to save ourselves a dependency, but that is not strictly required sed -i -e 's., "setuptools-git"..g' pyproject.toml +# the tests don't actually need mock, they use unittest.mock +# https://github.com/os-autoinst/openQA-python-client/pull/21 +sed -i '/mock/d' tests.requires + %generate_buildrequires %pyproject_buildrequires -t diff --git a/tests/python-pytest.spec b/tests/python-pytest.spec index 9693fcd..b9d0623 100644 --- a/tests/python-pytest.spec +++ b/tests/python-pytest.spec @@ -11,6 +11,13 @@ BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros +# no xmlschema packaged for EPEL 9 yet, cannot run tests on EPEL +%if 0%{?fedora} +%bcond_without tests +%else +%bcond_with tests +%endif + %description This is a pure Python package with executables. It has a test suite in tox.ini and test dependencies specified via the [test] extra. @@ -28,10 +35,13 @@ Summary: %{summary} %prep %autosetup -p1 -n %{pypi_name}-%{version} +# remove optional test dependencies we don't like to pull in +sed -E -i '/mock|nose/d' setup.cfg %generate_buildrequires -%pyproject_buildrequires -x testing -t +%pyproject_buildrequires %{?with_tests:-x testing -t} + %build %pyproject_wheel @@ -43,9 +53,13 @@ Summary: %{summary} %check +%if %{with tests} # Only run one test (which uses a test-only dependency, hypothesis) # See how to pass options trough the macro to tox, trough tox to pytest %tox -- -- -k metafunc +%else +%pyproject_check_import +%endif %files -n python3-%{pypi_name} -f %{pyproject_files} diff --git a/tests/python-setuptools.spec b/tests/python-setuptools.spec index 2e73e74..f6b67d3 100644 --- a/tests/python-setuptools.spec +++ b/tests/python-setuptools.spec @@ -13,6 +13,13 @@ BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: gcc +# too many missing tests deps in EPEL 9 +%if 0%{?fedora} +%bcond_without tests +%else +%bcond_with tests +%endif + %description This package tests 2 things: @@ -44,7 +51,7 @@ sed -i pytest.ini -e 's/ --flake8//' \ %generate_buildrequires -%pyproject_buildrequires -r -x testing +%pyproject_buildrequires -r %{?with_tests:-x testing} %build @@ -64,8 +71,12 @@ sed -i '/tests/d' %{pyproject_files} # https://github.com/pypa/setuptools/discussions/2607 rm pyproject.toml +%if %{with tests} # We only run a subset of tests to speed things up and be less fragile PYTHONPATH=$(pwd) %pytest --ignore=pavement.py -k "sdist" +%else +%pyproject_check_import +%endif # Internal check that license file was recognized correctly grep '^%%license' %{pyproject_files} > tested.license diff --git a/tests/python-setuptools_scm.spec b/tests/python-setuptools_scm.spec index 4d81244..7ecba7d 100644 --- a/tests/python-setuptools_scm.spec +++ b/tests/python-setuptools_scm.spec @@ -11,7 +11,13 @@ BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: /usr/bin/git -BuildRequires: /usr/bin/hg + +# flake8 is still missing tests deps in EPEL 9 +%if 0%{?fedora} +%bcond_without flake8 +%else +%bcond_with flake8 +%endif %description Here we test that %%pyproject_extras_subpkg works and generates @@ -37,7 +43,7 @@ Summary: %{summary} %generate_buildrequires # Note that you should not run flake8-like linters in Fedora spec files, # here we do it solely to check the *ability* to use multiple toxenvs. -%pyproject_buildrequires -e %{default_toxenv}-test -e flake8 +%pyproject_buildrequires -e %{default_toxenv}-test %{?with_flake8:-e flake8} %build @@ -56,7 +62,7 @@ Summary: %{summary} # Internal check for our macros: Assert both toxenvs were executed. grep -F 'py%{python3_version_nodots}-test: commands succeeded' toxlog -grep -F 'flake8: commands succeeded' toxlog +%{?!with_flake8:! }grep -F 'flake8: commands succeeded' toxlog # Internal check for our macros # making sure that %%{_pyproject_ghost_distinfo} has the right content