diff options
-rw-r--r-- | systemd/test/test_daemon.py | 15 |
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): |