summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-10-27 00:06:57 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-10-27 00:07:18 -0400
commitf83f19b3bd00fbe99de64b5c454d6c3e97dd890b (patch)
treea7b5327adbee8ed0d38ab226786c0f05eb77930b
parent3217d17d0cd8a1bff007b063ed787905e6d0d7ba (diff)
downloadpython-systemd-f83f19b3bd00fbe99de64b5c454d6c3e97dd890b.tar.gz
Python2 does not have ConnectionError
-rw-r--r--systemd/test/test_daemon.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/systemd/test/test_daemon.py b/systemd/test/test_daemon.py
index d3d3d6d..8dac870 100644
--- a/systemd/test/test_daemon.py
+++ b/systemd/test/test_daemon.py
@@ -205,18 +205,23 @@ def test_notify_no_socket():
assert notify('FDSTORE=1', pid=os.getpid()) == False
assert notify('FDSTORE=1', pid=os.getpid(), fds=(1,)) == False
+if sys.version_info >= (3,):
+ connection_error = ConnectionRefusedError
+else:
+ connection_error = OSError
+
def test_notify_bad_socket():
os.environ['NOTIFY_SOCKET'] = '/dev/null'
- with pytest.raises(ConnectionRefusedError):
+ with pytest.raises(connection_error):
notify('READY=1')
- with pytest.raises(ConnectionRefusedError):
+ with pytest.raises(connection_error):
notify('FDSTORE=1', fds=[])
- with pytest.raises(ConnectionRefusedError):
+ with pytest.raises(connection_error):
notify('FDSTORE=1', fds=[1,2])
- with pytest.raises(ConnectionRefusedError):
+ with pytest.raises(connection_error):
notify('FDSTORE=1', pid=os.getpid())
- with pytest.raises(ConnectionRefusedError):
+ with pytest.raises(connection_error):
notify('FDSTORE=1', pid=os.getpid(), fds=(1,))
def test_notify_with_socket(tmpdir):