def upload(self, report): """Upload the content in self._plots to dokuwiki. Parameters ---------- report : _pytest.runner.TestReport """ for plot, name in self._plots: plot_file = tempfile.NamedTemporaryFile(suffix=".png") axes = plot.axes[0] if report.passed: axes.text(0.8, 0.8, 'passed', transform=axes.transAxes, bbox={'facecolor': 'green', 'alpha': 0.5, 'pad': 10}) else: axes.text(0.8, 0.8, 'failed', transform=axes.transAxes, bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 10}) plot.savefig(plot_file.name) self.request.config.dokureport.doku_conn.medias.add( "reports:{0}:{1}.png".format(tardis.__githash__[0:7], name), plot_file.name ) self.plot_html.append(extras.html( thumbnail_html.format( dokuwiki_url=self.dokuwiki_url, githash=tardis.__githash__[0:7], name=name) ) ) plot_file.close()
def upload(self, report): """Upload content of ``self._plots`` to ``self.dokuwiki_url``. Parameters ---------- report : _pytest.runner.TestReport """ for plot, name in self._plots: plot_file = tempfile.NamedTemporaryFile(suffix=".png") self.save(plot, plot_file.name, report) self.request.config.dokureport.doku_conn.medias.add( "reports:{0}:{1}.png".format(tardis_githash[:7], name), plot_file.name, ) self.plot_html.append( extras.html( thumbnail_html_remote.format( dokuwiki_url=self.dokuwiki_url, githash=tardis_githash[:7], name=name, ) ) ) plot_file.close()
def pytest_runtest_makereport(__multicall__, item): report = __multicall__.execute() extra = getattr(report, 'extra', []) if report.when == 'call': desc = item.get_marker("desc") if desc is not None: for info in desc: if (info.args[0] and info.args[0] != ""): extra.append(extras.html(html.div(info.args[0]))) xfail = item.get_marker("xfail") if xfail is not None: for info in xfail: if info.kwargs and 'buglink' in info.kwargs: extra.append(extras.url(info.kwargs['buglink'])) skipif = item.get_marker("skipif") if skipif is not None: for info in skipif: if info.kwargs and 'buglink' in info.kwargs: extra.append(extras.url(info.kwargs['buglink'])) report.extra = extra return report
def upload(self, report): """Upload content of ``self._plots`` to ``self.dokuwiki_url``. Parameters ---------- report : _pytest.runner.TestReport """ for plot, name in self._plots: plot_file = tempfile.NamedTemporaryFile(suffix=".png") self.save(plot, plot_file.name, report) self.request.config.dokureport.doku_conn.medias.add( "reports:{0}:{1}.png".format(tardis_githash[:7], name), plot_file.name ) self.plot_html.append(extras.html( thumbnail_html_remote.format( dokuwiki_url=self.dokuwiki_url, githash=tardis_githash[:7], name=name) ) ) plot_file.close()
def upload(self, report): """Save content of ``self._plots`` to ``self.assets_dirpath``. Parameters ---------- report : _pytest.runner.TestReport """ for plot, name in self._plots: self.save(plot, os.path.join(self.assets_dirpath, "{0}.png".format(name)), report) self.plot_html.append(extras.html(thumbnail_html_local.format(name=name)))
def test_start_app(app, screenshot_path, extra, process_alive): """ Starts a test app to the welcome screen and creates a screenshot. """ assert app.existsAndVisible("mainWindow") assert app.existsAndVisible("mainWindow/welcomeScreen") first_title = app.getStringProperty( "mainWindow/welcomeScreen/loadProjectItem_1", "title") app.mouseClick("mainWindow/welcomeScreen/loadProjectItem_1") app.takeScreenshot("mainWindow", os.path.join(screenshot_path, "startup.png")) assert process_alive() extra.append(extras.html('<img src="images/startup.png"/>'))
def upload(self, report): """Save content of ``self._plots`` to ``self.assets_dirpath``. Parameters ---------- report : _pytest.runner.TestReport """ for plot, name in self._plots: self.save( plot, os.path.join(self.assets_dirpath, "{0}.png".format(name)), report) self.plot_html.append( extras.html(thumbnail_html_local.format(name=name)))
def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() report.description = str(item.function.__doc__) extra = getattr(report, 'extra', []) if report.when == 'call': # Grab test customized output (a custom variable tests can populate if needed test_reporter_keys = [ k for k in item.config._xml.node_reporters.keys() if k[0] == item.nodeid ] node_reporter = item.config._xml.node_reporters[test_reporter_keys[0]] pytest_output = item._testcase._pytest_output if "_pytest_output" in dir( item._testcase) else "" item.config._metadata = None # put in the HTML report extra.append( extras.html("<div class=\"log\">{}</div>".format(pytest_output))) report.extra = extra # put in the JUnit XML - our jira script will replace the \\n back node_reporter.add_property("pytest_output", pytest_output.replace("\n", "\\n"))
def _snap_image(rc): image = rc.run() img = yt.write_bitmap(image, None) content = base64.b64encode(img).decode("ascii") extra.append(extras.png(content)) extra.append(extras.html("<br clear='all'/>"))
def add_test_details_to_report(report, cfg): extra = getattr(report, 'extra', []) extra.append( extras.html( getattr(cfg, 'worker', '') + " " + getattr(cfg, 'username', ''))) report.extra = extra