def test_known_available(tmpdir): addr = tmpdir.join('known') s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM | socket.SOCK_CLOEXEC) s.bind(str(addr)) try: intf = Systemd(str(addr)) intf.available() finally: s.close()
def test_available(mock_sock): intf = Systemd() intf.available()
def test_available_ioerror(tmpdir): with mock.patch.dict('os.environ'): os.environ['NOTIFY_SOCKET'] = str(tmpdir.join('FOO')) intf = Systemd() with pytest.raises(RuntimeError): intf.available()
def test_available_invalid(): with mock.patch.dict('os.environ'): os.environ['NOTIFY_SOCKET'] = 'FOO' intf = Systemd() with pytest.raises(RuntimeError): intf.available()
def test_available_undefined(): intf = Systemd() with pytest.raises(RuntimeError): intf.available()