历史报告生成 Robotframework risto.py

Historical Report Generation Robotframework risto.py

当我运行 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

我不明白我哪里错了。

首先你没有做错。 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 的实际键。之后我更改了上面的代码片段,现在工作正常。

您必须修改并添加以下功能才能使 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

请进行差异比较以获取与原始文件的差异。