From f83f19b3bd00fbe99de64b5c454d6c3e97dd890b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 27 Oct 2015 00:06:57 -0400 Subject: Python2 does not have ConnectionError --- systemd/test/test_daemon.py | 15 ++++++++++----- 1 file 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): -- cgit v1.2.1