1
0
python-systemd/OBS_missing_etc_machine_id.patch
Matej Cepl bfb15f2c94 - 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
2024-05-13 18:04:54 +00:00

49 lines
1.3 KiB
Diff

From 50d1ec8ab8d3333ef1b7cac982155b94c7534c4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Wed, 17 Aug 2022 09:53:25 +0200
Subject: [PATCH] tests: check for errnos that sd_id128_get_machine actually
returns
Fixes #118.
---
systemd/test/test_id128.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
--- a/systemd/test/test_id128.py
+++ b/systemd/test/test_id128.py
@@ -6,11 +6,11 @@ import pytest
from systemd import id128
@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
@@ -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):
+ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123):
u1 = id128.get_machine_app_specific(a1)
u2 = id128.get_machine_app_specific(a2)