def test_pid_by_open_file_lsof(self, call_mock): """ Tests the 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.assertEqual(4762, system.pid_by_open_file('/tmp/foo')) call_mock.return_value = [] call_mock.side_effect = None self.assertEqual(None, system.pid_by_open_file('/tmp/somewhere_else'))