def test_set_pid_valid_path(): daemon = Daemon('/fake/path.pid') m_open = mock.mock_open() with mock.patch('builtins.open', m_open, create=True): daemon.pid = 123 m_open.assert_called_once_with('/fake/path.pid', 'w+')
def test_set_pid_invalid_path(_): daemon = Daemon('/fake/path.pid') with pytest.raises(DaemonException): daemon.pid = 123