gpt4 book ai didi

python - 如何使用 Rally API 获取测试用例名称

转载 作者:行者123 更新时间:2023-12-01 05:14:42 26 4
gpt4 key购买 nike

我正在尝试编写一个循环,该循环将返回包含测试集和测试用例的表。但是,我无法获取测试用例的名称,但 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</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')

tc.FormattedID 给我一个属性错误。见下文

 print >> fh, template.render(**workContext)

File "C:\Python27\lib\site-packages\mako\template.py", line 397, in render
return runtime._render(self, self.callable_, args, data)

File "C:\Python27\lib\site-packages\mako\runtime.py", line 764, in _render
**_kwargs_for_callable(callable_, data))

File "C:\Python27\lib\site-packages\mako\runtime.py", line 796, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File "C:\Python27\lib\site-packages\mako\runtime.py", line 822, in _exec_template
callable_(context, *args, **kwargs)

File "C:\Users\xxx\Documents\xx\tools\xxx\tmp\audit.base.html.py", line 130, in render_body

context['self'].content(**pageargs)
File "C:\Users\xxx\Documents\TOOLS_WS\tools\xxxx\tmp\Validation Test Plan.html.py", line 171, in render_content
__M_writer(filters.html_escape(unicode(tc.FormattedID)))
AttributeError: 'list' object has no attribute 'FormattedID'

请需要帮助。谢谢

最佳答案

碰巧我在代码中缺少一个“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')

干杯。

关于python - 如何使用 Rally API 获取测试用例名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23436225/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com