- Add fix_test_reader_this_machine.patch to make

test_reader_this_machine pass in the limited build environment.
- Do not pull in whole systemd, when just libsystemd0 is enough
  (bsc#1215538).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-systemd?expand=0&rev=29
This commit is contained in:
Matej Cepl 2024-05-13 18:04:54 +00:00 committed by Git OBS Bridge
parent 4c4b57ba8e
commit bfb15f2c94
4 changed files with 65 additions and 11 deletions

View File

@ -6,14 +6,12 @@ Subject: [PATCH] tests: check for errnos that sd_id128_get_machine actually
Fixes #118.
---
systemd/test/test_id128.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
systemd/test/test_id128.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/systemd/test/test_id128.py b/systemd/test/test_id128.py
index 146ec73..f5fc65f 100644
--- a/systemd/test/test_id128.py
+++ b/systemd/test/test_id128.py
@@ -6,11 +6,11 @@
@@ -6,11 +6,11 @@ import pytest
from systemd import id128
@contextlib.contextmanager
@ -27,13 +25,24 @@ index 146ec73..f5fc65f 100644
pytest.skip()
raise
@@ -29,7 +29,8 @@ def test_get_machine_app_specific():
@@ -21,7 +21,10 @@ def test_randomize():
assert u1 != u2
def test_get_machine():
- u1 = id128.get_machine()
+ # yikes, python2 doesn't know ENOMEDIUM
+ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123):
+ u1 = id128.get_machine()
+
u2 = id128.get_machine()
assert u1 == u2
@@ -29,7 +32,7 @@ def test_get_machine_app_specific():
a1 = uuid.uuid1()
a2 = uuid.uuid1()
- with skip_oserror(errno.ENOSYS):
+ # yikes, python2 doesn't know ENOMEDIUM
+ with skip_oserror(errno.ENOENT, 123):
+ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123):
u1 = id128.get_machine_app_specific(a1)
u2 = id128.get_machine_app_specific(a2)

View File

@ -0,0 +1,34 @@
---
systemd/test/test_journal.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--- a/systemd/test/test_journal.py
+++ b/systemd/test/test_journal.py
@@ -43,11 +43,11 @@ class MockSender:
self.buf.append(args)
@contextlib.contextmanager
-def skip_oserror(code):
+def skip_oserror(*errnos):
try:
yield
except (OSError, IOError) as e:
- if e.errno == code:
+ if e.errno in errnos:
pytest.skip()
raise
@@ -233,9 +233,10 @@ def test_reader_this_boot(tmpdir):
def test_reader_this_machine(tmpdir):
j = journal.Reader(path=tmpdir.strpath)
with j:
- j.this_machine()
- j.this_machine(TEST_MID)
- j.this_machine(TEST_MID.hex)
+ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123):
+ j.this_machine()
+ j.this_machine(TEST_MID)
+ j.this_machine(TEST_MID.hex)
def test_reader_query_unique(tmpdir):
j = journal.Reader(path=tmpdir.strpath)

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon May 13 18:03:23 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
- Add fix_test_reader_this_machine.patch to make
test_reader_this_machine pass in the limited build environment.
- Do not pull in whole systemd, when just libsystemd0 is enough
(bsc#1215538).
-------------------------------------------------------------------
Sun Jun 11 14:08:18 UTC 2023 - ecsos <ecsos@opensuse.org>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-systemd
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -30,6 +30,9 @@ Patch1: iso-c-90.patch
# PATCH-FIX-OPENSUSE OBS_missing_etc_machine_id.patch gh#systemd/python-systemd#118 mcepl@suse.com
# build environment doesn't have /etc/machine-id
Patch2: OBS_missing_etc_machine_id.patch
# PATCH-FIX-UPSTREAM fix_test_reader_this_machine.patch mcepl@suse.com
# make test_reader_this_machine test pass in the limited build environment
Patch3: fix_test_reader_this_machine.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
@ -39,7 +42,7 @@ BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(libsystemd)
Requires: systemd
Requires: libsystemd0
Suggests: %{name}-doc
# /SECTION
BuildRequires: %{python_module pytest}
@ -64,7 +67,7 @@ Python module for native access to the systemd facilities. Functionality is sepe
%check
# Not sure about the first exclusion,
export PYTEST_ADDOPTS="-k 'not (test_reader_this_machine or test_get_machine)'"
# export PYTEST_ADDOPTS="-k 'not (test_reader_this_machine or test_get_machine)'"
%python_expand make PYTHON=python%{$python_version} check
%files %{python_files}