コード例 #1
0
ファイル: json_to_pdf.py プロジェクト: morganstanley/testplan
def main(source, target):

    with open(source) as source_file:
        data = json.loads(source_file.read())
        if data.get("version", 1) >= 2 or len(data.get("entries", [])) == 0:
            raise RuntimeError(
                "This utility can only process a single all-in-one JSON"
                " report, you can set `split_json_report` to False in"
                " `JSONExporter` while running Testplan script to get a"
                " single JSON report.")

        report_obj = TestReport.deserialize(data)
        print("Loaded report: {}".format(report_obj.name))

        # We can initialize an exporter object directly, without relying on
        # Testplan internals to trigger the export operation.
        exporter = PDFExporter(
            pdf_path=target,
            pdf_style=Style(
                passing=StyleEnum.ASSERTION_DETAIL,
                failing=StyleEnum.ASSERTION_DETAIL,
            ),
        )

        exporter.export(report_obj)
コード例 #2
0
ファイル: writers.py プロジェクト: morganstanley/testplan
 def __call__(self, result: TestReport) -> TestReport:
     """
     :param result: Testplan report to export
     """
     exporter = PDFExporter(
         pdf_path=self.filename, pdf_style=self.style.value
     )
     exporter.create_pdf(result)
     self.logger.test_info(f"PDF written to {self.filename}")
     return result
コード例 #3
0
def test_local_pool_integration(
    report_dir,
    multitest_maker,
    expected_report,
    pdf_title,
    expected_plan_result,
    dependant_module,
):
    if dependant_module:
        importorxfail(dependant_module)

    pdf_path = report_dir.join(
        "test_report_local_{}.pdf".format(pdf_title)).strpath
    plan = Testplan(
        name="plan",
        parse_cmdline=False,
        exporters=[PDFExporter.with_config(pdf_path=pdf_path)],
    )

    plan.add(multitest_maker())

    assert not os.path.exists(pdf_path)

    with log_propagation_disabled(TESTPLAN_LOGGER):
        assert plan.run().run is True

    for log in plan.report.flattened_logs:
        if all(word in log["message"] for word in ["tkinter", "TclError"]):
            pytest.xfail(reason="Tkinter not installed properly")

    check_report(expected=expected_report, actual=plan.report)

    assert plan.result.success is expected_plan_result
    assert os.path.exists(pdf_path)
    assert os.stat(pdf_path).st_size > 0
コード例 #4
0
ファイル: json_to_pdf.py プロジェクト: petrkalos/testplan
def main(source, target):

    with open(source) as source_file:
        data = json.loads(source_file.read())
        report_obj = TestReport.deserialize(data)

        print('Loaded report: {}'.format(report_obj.name))

        # We can initialize an exporter object directly, without relying on
        # Testplan internals to trigger the export operation.
        exporter = PDFExporter(pdf_path=target,
                               pdf_style=Style(
                                   passing=StyleEnum.ASSERTION_DETAIL,
                                   failing=StyleEnum.ASSERTION_DETAIL))

        exporter.export(report_obj)
コード例 #5
0
ファイル: test_runner_e2e.py プロジェクト: pymmrd/testplan
def test_process_pool_integration(
    report_dir, fixture_dirname,
    expected_report, pdf_title,
    expected_plan_result, dependant_module
):
    if dependant_module:
        importorxfail(dependant_module)

    pool = ProcessPool(name='MyPool', size=1)
    pdf_path = report_dir.join('test_report_process_{}.pdf'.format(
        pdf_title)).strpath

    plan = Testplan(
        name='plan',
        parse_cmdline=False,
        exporters=[
            PDFExporter(pdf_path=pdf_path)
        ]
    )
    plan.add_resource(pool)

    runners_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    fixture_path = os.path.join(runners_path, 'fixtures', fixture_dirname)

    task = Task(
        target='make_multitest',
        module='suites',
        path=fixture_path,
    )
    plan.schedule(task, resource='MyPool')

    assert not os.path.exists(pdf_path)

    with log_propagation_disabled(TESTPLAN_LOGGER):
        assert plan.run().run is True

    for log in plan.report.flattened_logs:
        if all(word in log['message'] for word in ['tkinter', 'TclError']):
            pytest.xfail(reason='Tkinter not installed properly')

    check_report(expected=expected_report, actual=plan.report)

    assert plan.result.success is expected_plan_result
    assert os.path.exists(pdf_path)
    assert os.stat(pdf_path).st_size > 0
コード例 #6
0
def test_process_pool_integration(
    runpath,
    fixture_dirname,
    expected_report,
    pdf_title,
    expected_plan_result,
    dependant_module,
):
    if dependant_module:
        importorxfail(dependant_module)

    pool = ProcessPool(name="MyProcessPool", size=1)
    pdf_path = os.path.join(
        runpath, "test_report_local_{}.pdf".format(pdf_title)
    )

    plan = TestplanMock(
        name="plan",
        exporters=[PDFExporter(pdf_path=pdf_path)],
        runpath=runpath,
    )
    plan.add_resource(pool)

    runners_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    fixture_path = os.path.join(runners_path, "fixtures", fixture_dirname)

    task = Task(target="make_multitest", module="suites", path=fixture_path)
    plan.schedule(task, resource="MyProcessPool")

    assert not os.path.exists(pdf_path)

    with log_propagation_disabled(TESTPLAN_LOGGER):
        assert plan.run().run is True

    for log in plan.report.flattened_logs:
        if all(word in log["message"] for word in ["tkinter", "TclError"]):
            pytest.xfail(reason="Tkinter not installed properly")

    check_report(expected=expected_report, actual=plan.report)

    assert plan.result.success is expected_plan_result
    assert os.path.exists(pdf_path)
    assert os.stat(pdf_path).st_size > 0