Skip to content

Commit 177ac6d

Browse files
committed
tests: skip fdstore tests if not implemented
Should fix #12.
1 parent 34ce130 commit 177ac6d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

systemd/test/test_daemon.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515

1616
import pytest
1717

18+
@contextlib.contextmanager
19+
def skip_enosys():
20+
try:
21+
yield
22+
except OSError as e:
23+
if e.errno == errno.ENOSYS:
24+
pytest.skip()
25+
raise
26+
1827
@contextlib.contextmanager
1928
def closing_socketpair(family):
2029
pair = socket.socketpair(family)
@@ -200,7 +209,8 @@ def test_listen_fds_default_unset():
200209

201210
def test_notify_no_socket():
202211
assert notify('READY=1') == False
203-
assert notify('FDSTORE=1', fds=[]) == False
212+
with skip_enosys():
213+
assert notify('FDSTORE=1', fds=[]) == False
204214
assert notify('FDSTORE=1', fds=[1,2]) == False
205215
assert notify('FDSTORE=1', pid=os.getpid()) == False
206216
assert notify('FDSTORE=1', pid=os.getpid(), fds=(1,)) == False
@@ -216,7 +226,8 @@ def test_notify_bad_socket():
216226
with pytest.raises(connection_error):
217227
notify('READY=1')
218228
with pytest.raises(connection_error):
219-
notify('FDSTORE=1', fds=[])
229+
with skip_enosys():
230+
notify('FDSTORE=1', fds=[])
220231
with pytest.raises(connection_error):
221232
notify('FDSTORE=1', fds=[1,2])
222233
with pytest.raises(connection_error):
@@ -234,7 +245,8 @@ def test_notify_with_socket(tmpdir):
234245
os.environ['NOTIFY_SOCKET'] = path
235246

236247
assert notify('READY=1') == True
237-
assert notify('FDSTORE=1', fds=[]) == True
248+
with skip_enosys():
249+
assert notify('FDSTORE=1', fds=[]) == True
238250
assert notify('FDSTORE=1', fds=[1,2]) == True
239251
assert notify('FDSTORE=1', pid=os.getpid()) == True
240252
assert notify('FDSTORE=1', pid=os.getpid(), fds=(1,)) == True

0 commit comments

Comments
 (0)