def test_get_file_info(self, mock_subproc_popen): process_mock = mock.Mock() attrs = {'communicate.return_value': ( "projectRequirements.txt", '')} process_mock.configure_mock(**attrs) mock_subproc_popen.return_value = process_mock x = get_file_info("projectRequirements.txt") self.assertTrue(x) self.assertTrue(mock_subproc_popen.called)
def test_get_file_info(self, mock_subproc_popen): """ func to test the file info with abs path :param mock_subproc_popen: :return: valid if the file exist as abs path """ process_mock = mock.Mock() attrs = {'communicate.return_value': ( "projectRequirements.txt", '')} process_mock.configure_mock(**attrs) mock_subproc_popen.return_value = process_mock value = get_file_info("projectRequirements.txt") self.assertTrue(value) self.assertTrue(mock_subproc_popen.called)