Skip to content

Commit 35a5b28

Browse files
committed
tests: add workaround for pre-232 system returning EINVAL on some flags
1 parent c3c412f commit 35a5b28

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

systemd/test/test_journal.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ def skip_enosys():
2121
pytest.skip()
2222
raise
2323

24+
@contextlib.contextmanager
25+
def skip_valueerror():
26+
try:
27+
yield
28+
except ValueError:
29+
pytest.skip()
30+
2431
def test_priorities():
2532
p = journal.JournalHandler.mapPriority
2633

@@ -62,10 +69,12 @@ def test_reader_init_flags():
6269
def test_reader_os_root(tmpdir):
6370
with pytest.raises(ValueError):
6471
journal.Reader(journal.OS_ROOT)
65-
j1 = journal.Reader(path=tmpdir.strpath,
66-
flags=journal.OS_ROOT)
67-
j2 = journal.Reader(path=tmpdir.strpath,
68-
flags=journal.OS_ROOT | journal.CURRENT_USER)
72+
with skip_valueerror():
73+
j1 = journal.Reader(path=tmpdir.strpath,
74+
flags=journal.OS_ROOT)
75+
with skip_valueerror():
76+
j2 = journal.Reader(path=tmpdir.strpath,
77+
flags=journal.OS_ROOT | journal.CURRENT_USER)
6978
j3 = journal.Reader(path=tmpdir.strpath,
7079
flags=journal.OS_ROOT | journal.SYSTEM_ONLY)
7180

@@ -91,7 +100,8 @@ def test_reader_init_path_fd(tmpdir):
91100
j1 = journal.Reader(path=fd)
92101
assert list(j1) == []
93102

94-
j2 = journal.Reader(journal.SYSTEM, path=fd)
103+
with skip_valueerror():
104+
j2 = journal.Reader(journal.SYSTEM, path=fd)
95105
assert list(j2) == []
96106

97107
j3 = journal.Reader(journal.CURRENT_USER, path=fd)

0 commit comments

Comments
 (0)