我正在尝试编写一个循环,该循环将返回一个包含测试集和测试用例的表。但是,我无法获得测试用例的名称,但会返回“对象 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'
请需要帮助。谢谢