Skip to content

Commit e29ab4a

Browse files
committed
Add %check section to run pytest at build time
1 parent c98ec19 commit e29ab4a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

package/python-kiwi-spec-template

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
# If they aren't provided by a system installed macro, define them
2121
%{!?_defaultdocdir: %global _defaultdocdir %{_datadir}/doc}
2222

23+
# Userland install of python modules such that new namespaces
24+
# gets added to this environment properly. I did not find another
25+
# way to install a python module as non root into this build environment
26+
# such that importlib.* methods would find them. With the former
27+
# pkg_resources this could be handled by setting the PYTHONPATH
28+
# variable but this doesn't work anymore with importlib.
29+
%global pip_install pip install --break-system-packages
30+
2331
%if 0%{?suse_version} && 0%{?suse_version} < 1600
2432
%global __python3 /usr/bin/python3.11
2533
%global python3_pkgversion 311
@@ -69,6 +77,12 @@ Source1: %{name}-rpmlintrc
6977
## PATCH-FIX-OPENSUSE kiwi-revert-bls-default-for-suse.patch -- temporary until opensuse has bls
7078
Patch1001: kiwi-revert-bls-default-for-suse.patch
7179
BuildRoot: %{_tmppath}/%{name}-%{version}-build
80+
BuildRequires: kiwi-systemdeps
81+
BuildRequires: python%{python3_pkgversion}-pytest
82+
BuildRequires: python%{python3_pkgversion}-pip
83+
BuildRequires: python%{python3_pkgversion}-anymarkup-core
84+
BuildRequires: python%{python3_pkgversion}-toml
85+
BuildRequires: python%{python3_pkgversion}-xmltodict
7286
%if 0%{?fedora} || 0%{?suse_version}
7387
BuildRequires: fdupes
7488
%endif
@@ -755,6 +769,11 @@ fi
755769
%endif
756770
%endif
757771

772+
%check
773+
# install kiwi to userland and run the tests
774+
%pip_install dist/kiwi-%{version}-py3-none-any.whl
775+
cd test/unit && pytest
776+
758777
%files -n kiwi-systemdeps-core
759778
# Empty metapackage
760779

0 commit comments

Comments
 (0)