历史报告生成Robotframework risto.py

时间:2015-05-22 06:30:03

标签: robotframework

当我运行risto.py生成历史报告(图表)时,我收到以下错误:

#risto.py --output history.png output.xml output1.xml
Traceback (most recent call last):
    File "/usr/local/bin/risto.py", line 505, in <module>
       Ristopy().main (sys.argv [1:])
    File "/usr/local/bin/risto.py", line 428, in main
       viewer_open = self.plot_one_graph (args)
    File "/usr/local/bin/risto.py", line 442, in _plot_one_graph
       output = self._plot (stats, opts)
    File "/usr/local/bin/risto.py", line 455, in _plot
       plotter = Plotter (opts['tag'], not opts['nocritical'],
KeyError: 'nocritical'

#risto.py --version
risto.py 1.0.2

我不明白我哪里出错了。

2 个答案:

答案 0 :(得分:2)

首先,你没有犯任何错误。 risto.py代码本身存在一个错误(第461行):

plotter = Plotter(opts['tag'],  not opts['nocritical'],
                      not opts['noall'], not opts['nototals'],
                      not opts['nopassed'], not opts['nofailed'],
                      opts['width'], opts['height'], opts['font'],
                      opts['marker'], opts['xticks'])

将其替换为以下内容:

plotter = Plotter(opts['tag'],  opts['critical'],
                      opts['all'], opts['totals'],
                      opts['passed'], opts['failed'],
                      opts['width'], opts['height'], opts['font'],
                      opts['marker'], opts['xticks'])

实际上这是函数def _plot(self,stats,opts):由以下函数调用:

def _plot_one_graph(self, args):
    opts, paths = self._arg_parser.parse_args(args)
    stats = AllStatistics(paths, opts['namemeta'], opts['verbose'])
    output = self._plot(stats, opts)
    return output is None

如果在此函数中打印opts,您将获得字典opts的实际键。之后我改变了上面的代码片段,现在工作正常。

答案 1 :(得分:2)

您必须修改并添加以下函数才能使risto正常工作:

def _plot_one_graph(self, args):
    opts, paths = self._arg_parser.parse_args(args)
    opts = self._handle_options(opts)
    stats = AllStatistics(paths, opts['namemeta'], opts['verbose'])
    output = self._plot(stats, opts)
    return output is None

def _handle_options(self, opts):
    if opts.get('critical') is None:
        opts['critical'] = True
    if opts.get('all') is None:
        opts['all'] = True
    if opts.get('totals') is None:
        opts['totals'] = True
    if opts.get('passed') is None:
        opts['passed'] = True
    if opts.get('failed') is None:
        opts['failed'] = True
    return opts

请做差异以获得原始文件的差异。