def test_create_pdf(tmpdir): """PDF exporter should generate a PDF file using the report data.""" pdf_path = tmpdir.mkdir("reports").join("dummy_report.pdf").strpath assertion_entries = [ assertions.Equal(1, 2), assertions.Greater(2, 1), assertions.IsFalse(True, "this should fail"), assertions.IsTrue(True, "this should pass"), assertions.Fail("Explicit failure"), base.Group( description="group description", entries=[ assertions.NotEqual(2, 1), assertions.Contain(1, [1, 2, 3]), ], ), ] # Test large assertion for _ in range(10): assertion_entries.append( assertions.RegexMatch("Test.*", "Testplan\n" * 500)) report = TestReport( name="my testplan", entries=[ TestGroupReport( name="My Multitest", category=ReportCategories.MULTITEST, entries=[ TestGroupReport( name="MySuite", category=ReportCategories.TESTSUITE, entries=[ TestCaseReport( name="my_test_method", entries=[ registry.serialize(obj) for obj in assertion_entries ], ) ], ) ], ) ], ) exporter = PDFExporter( pdf_path=pdf_path, pdf_style=styles.Style(passing="assertion-detail", failing="assertion-detail"), ) with log_propagation_disabled(TESTPLAN_LOGGER): exporter.export(report) assert os.path.exists(pdf_path) assert os.stat(pdf_path).st_size > 0
def test_create_pdf(tmpdir): """PDF exporter should generate a PDF file using the report data.""" pdf_path = tmpdir.mkdir('reports').join('dummy_report.pdf').strpath assertion_entries = [ assertions.Equal(1, 2), assertions.Greater(2, 1), assertions.IsFalse(True, 'this should fail'), assertions.IsTrue(True, 'this should pass'), assertions.Fail('Explicit failure'), base.Group( description='group description', entries=[ assertions.NotEqual(2, 1), assertions.Contain(1, [1, 2, 3]), ] ) ] report = TestReport( name='my testplan', entries=[ TestGroupReport( name='My Multitest', category='multitest', entries=[ TestGroupReport( name='MySuite', entries=[ TestCaseReport( name='my_test_method', entries=[ registry.serialize(obj) for obj in assertion_entries ] ) ] ) ] ) ] ) exporter = PDFExporter( pdf_path=pdf_path, pdf_style=styles.Style( passing='assertion-detail', failing='assertion-detail' ) ) with log_propagation_disabled(TESTPLAN_LOGGER): exporter.export(report) assert os.path.exists(pdf_path) assert os.stat(pdf_path).st_size > 0