Python 如何使用rally API获取测试用例名称
我试图编写一个循环,返回一个包含测试集和测试用例的表。然而,我无法获得测试用例的名称,但是rally返回了一个“对象ID(OID)”Python 如何使用rally API获取测试用例名称,python,html,rally,mako,pyral,Python,Html,Rally,Mako,Pyral,我试图编写一个循环,返回一个包含测试集和测试用例的表。然而,我无法获得测试用例的名称,但是rally返回了一个“对象ID(OID)” _M_writer(u'</p>\r\n<table class="objects" style="width: 60%">\r\n\t\t<tr>\r\n\t\t\t<th>TestSets</td>\r\n\t\t\t<th>TestCases</th>\r\n\t\t<
_M_writer(u'</p>\r\n<table class="objects" style="width: 60%">\r\n\t\t<tr>\r\n\t\t\t<th>TestSets</td>\r\n\t\t\t<th>TestCases</th>\r\n\t\t</tr>\r\n')
for ts in testSets:
__M_writer(u'\t\t\t\t')
tc = ts.TestCases
if tc:
__M_writer(u'<tr>')
__M_writer(u'<td>')
__M_writer(unicode(ts.FormattedID))
__M_writer(u'\t\t\t\t</td>')
__M_writer(u'<td>')
__M_writer(filters.html_escape(unicode(tc.FormattedID)))
__M_writer(u'</td>')
__M_writer(u'</tr>\r\n')
pass
__M_writer(u'</table>\n')
请需要帮助。谢谢这不是Python特有的,但必须显式地获取名称才能访问它。尝试使用
tc.\u reobjectname
。不需要获取\u reobjectname
,它与名称相同。恰好我的代码中缺少了一个“for循环:
ts.TestCases`正在返回测试用例列表,而不是单个测试用例
更正的代码如下所示:
__M_writer(u'</p>\r\n<table class="objects" style="width: 60%">\r\n\t\t<tr>\r\n\t\t\t<th>TestSets</td>\r\n\t\t\t<th>TestCases</th>\r\n\t\t</tr>\r\n')
for ts in testSets:
__M_writer(u'\t\t\t\t')
testCaseObjectList = ts.TestCases
for tc in testCaseObjectList:
if tc:
__M_writer(u'<tr>')
__M_writer(u'<td>')
__M_writer(unicode(ts.FormattedID))
__M_writer(u'\t\t\t\t</td>')
__M_writer(u'<td>')
__M_writer(filters.html_escape(unicode(tc.FormattedID)))
__M_writer(u'</td>')
__M_writer(u'</tr>\r\n')
pass
__M_writer(u'</table>\n')
\u\M\u writer(u'\r\n\r\n\t\t\r\n\t\t\t测试用例\r\n\t\t\t测试用例\r\n\t\t\r\n')
对于测试集中的ts:
__M_writer(u'\t\t\t\t')
testCaseObjectList=ts.TestCases
对于testCaseObjectList中的tc:
如果tc:
__M_编写器(u“”)
__M_编写器(u“”)
__M_writer(unicode(ts.FormattedID))
__M_writer(u'\t\t\t\t')
__M_编写器(u“”)
__M_writer(filters.html_escape(unicode(tc.FormattedID)))
__M_编写器(u“”)
__M_writer(u'\r\n')
通过
__M_writer(u'\n')
干杯。您能检查一下代码格式吗?我仍然遇到了这个错误:u M_writer(filters.html_escape(unicode(tc._reobjectname)))AttributeError:'list'对象没有属性'\u reobjectname'注意,如果测试集没有测试用例,可能会引发错误
__M_writer(u'</p>\r\n<table class="objects" style="width: 60%">\r\n\t\t<tr>\r\n\t\t\t<th>TestSets</td>\r\n\t\t\t<th>TestCases</th>\r\n\t\t</tr>\r\n')
for ts in testSets:
__M_writer(u'\t\t\t\t')
testCaseObjectList = ts.TestCases
for tc in testCaseObjectList:
if tc:
__M_writer(u'<tr>')
__M_writer(u'<td>')
__M_writer(unicode(ts.FormattedID))
__M_writer(u'\t\t\t\t</td>')
__M_writer(u'<td>')
__M_writer(filters.html_escape(unicode(tc.FormattedID)))
__M_writer(u'</td>')
__M_writer(u'</tr>\r\n')
pass
__M_writer(u'</table>\n')