def test_get_pid_by_open_file_lsof(self): """ Tests the get_pid_by_open_file function with a lsof response. """ lsof_query = system.GET_PID_BY_FILE_LSOF % "/tmp/foo" mocking.mock(system.call, mock_call(lsof_query, ["4762"])) self.assertEquals(4762, system.get_pid_by_open_file("/tmp/foo")) self.assertEquals(None, system.get_pid_by_open_file("/tmp/somewhere_else"))
def test_get_pid_by_open_file_lsof(self, call_mock): """ Tests the get_pid_by_open_file function with a lsof response. """ lsof_query = system.GET_PID_BY_FILE_LSOF % "/tmp/foo" call_mock.side_effect = mock_call(lsof_query, ["4762"]) self.assertEquals(4762, system.get_pid_by_open_file("/tmp/foo")) call_mock.return_value = [] call_mock.side_effect = None self.assertEquals(None, system.get_pid_by_open_file("/tmp/somewhere_else"))