Skip to content

Commit f83f19b

Browse files
committed
Python2 does not have ConnectionError
1 parent 3217d17 commit f83f19b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

systemd/test/test_daemon.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,23 @@ def test_notify_no_socket():
205205
assert notify('FDSTORE=1', pid=os.getpid()) == False
206206
assert notify('FDSTORE=1', pid=os.getpid(), fds=(1,)) == False
207207

208+
if sys.version_info >= (3,):
209+
connection_error = ConnectionRefusedError
210+
else:
211+
connection_error = OSError
212+
208213
def test_notify_bad_socket():
209214
os.environ['NOTIFY_SOCKET'] = '/dev/null'
210215

211-
with pytest.raises(ConnectionRefusedError):
216+
with pytest.raises(connection_error):
212217
notify('READY=1')
213-
with pytest.raises(ConnectionRefusedError):
218+
with pytest.raises(connection_error):
214219
notify('FDSTORE=1', fds=[])
215-
with pytest.raises(ConnectionRefusedError):
220+
with pytest.raises(connection_error):
216221
notify('FDSTORE=1', fds=[1,2])
217-
with pytest.raises(ConnectionRefusedError):
222+
with pytest.raises(connection_error):
218223
notify('FDSTORE=1', pid=os.getpid())
219-
with pytest.raises(ConnectionRefusedError):
224+
with pytest.raises(connection_error):
220225
notify('FDSTORE=1', pid=os.getpid(), fds=(1,))
221226

222227
def test_notify_with_socket(tmpdir):

0 commit comments

Comments
 (0)