0

我正在使用 python 集会工具包版本 1.4.2 来执行 get 和 put 操作,但有时每当我运行我的代码时,我都会收到此错误:“”“文件”/Library/Frameworks/Python.framework/Versions/3.8/lib/python3。 8/site-packages/pyral/rallyresp.py",第 303 行,在下一个 if (self._served >= self._servable) 或 (self._limit and self._served >= self._limit): AttributeError: 'RallyRESTResponse'对象没有属性 '_servable' """

在多次重新运行相同的代码时,代码可以工作,有时却不能。以下是会引发异常的 rallyresp.py 文件中的代码。

        if (self._served >= self._servable) or (self._limit and self._served >= self._limit):
        raise StopIteration

这是我完整的python代码:

class TestExecutionDetails():
def __init__(self):
    self.testCaseDetailDict = collections.defaultdict(list)
    self.userStoryDetailDict = collections.defaultdict(list)
    self.conf = ConfigObj("config.ini")
    self.server = self.conf['RallyWS_P']['server']
    self.ws = self.conf['RallyWS_P']['workspace']
    self.prj = self.conf['RallyWS_P']['project']
    self.apikey = self.conf['LoginCredentials']['apikey']
    self.userStoryHeaderCount = 0
    self.testCaseHeaderCount = 0

    print(self.apikey,"\t\t",self.server,"\t\t",self.ws,"\t\t",self.prj)
    self.rally = Rally(self.server, apikey=self.apikey, workspace=self.ws, project=self.prj)
    self.rally.enableLogging('rally.simple-use.log')

def getTestExecutionInfo(self):
    story = self.rally.get('UserStory', query='Release.Name contains "AXP PI 20.2" AND Iteration.Name contains "AXP 20.2.10 IP"', fetch=True,order="Iteration,FormattedID")

    if not story.errors:
        for s in story:
            self.userStoryDetailDict['FormattedID'].append(s.FormattedID)
            self.userStoryDetailDict['Iteration'].append(s.Iteration.Name)
            self.userStoryDetailDict['Release'].append(s.Release.Name)
            self.userStoryDetailDict['LastBuild'].append(s.LastBuild)
            self.userStoryDetailDict['LastRun'].append(str(s.LastRun).split('T')[0])
            self.userStoryDetailDict['Owner'].append(s.Owner.DisplayName)
            self.userStoryDetailDict['TcCount'].append(s.TestCaseCount)
            self.userStoryDetailDict['PassingTcCount'].append(s.PassingTestCaseCount)
            self.userStoryDetailDict['TcStatus'].append(s.TestCaseStatus)
            for t in s.TestCases:
                #print(t.Owner,"\t\t",t.Owner.DisplayName)
                self.testCaseDetailDict['FormattedID'].append(t.FormattedID)
                self.testCaseDetailDict['CreatedBy'].append(t.CreatedBy.DisplayName)
                if t.Owner is None:
                    self.testCaseDetailDict['Owner'].append("None")
                else:
                    self.testCaseDetailDict['Owner'].append(t.Owner.DisplayName)
                self.testCaseDetailDict['LastBuild'].append(t.LastBuild)
                #self.testCaseDetailDict['LastResult'].append(t.TestCaseResult.Name)
                self.testCaseDetailDict['LastRun'].append(str(t.LastRun).split('T')[0])
                self.testCaseDetailDict['LastUpdateDate'].append(str(t.LastUpdateDate).split('T')[0])
                self.testCaseDetailDict['LastVerdict'].append(t.LastVerdict)
                #self.testCaseDetailDict['Attachments'].append(t.Attachement.Name)
                
        self.userStoryHeaderCount = len(self.userStoryDetailDict.keys())
        self.testCaseHeaderCount = len(self.testCaseDetailDict.keys())
        print(self.testCaseDetailDict)
        print(self.userStoryDetailDict)


if __name__ == '__main__':
ted = TestExecutionDetails()
ted.getTestExecutionInfo()
4

1 回答 1

0

正如@ewong 所建议的,这确实是一个网络问题。由于我们大多数人都在家工作,由于互联网连接,连接在中间丢失了。我为此尝试的解决方案是添加最多 5 次重试。

于 2020-06-29T06:45:36.470 回答