def test_double_summary_prevention(): """ Summary.summarize should flatten Group.entries and include other Summary entries directly. """ asr_1 = assertions.Equal(1, 1) asr_2 = assertions.Equal(2, 2) asr_3 = base.Group( entries=[assertions.Equal(3, 3), assertions.Equal(3, 3)]) asr_4 = base.Summary( entries=[assertions.IsTrue(True), assertions.Greater(3, 2)]) asr_5 = assertions.Equal(3, 3) summary = base.Summary( entries=[asr_1, asr_2, asr_3, asr_4, asr_5], num_passing=5, ) assert len(summary.entries) == 2 existing_summary, category_group = summary.entries assert isinstance(category_group, base.Group) assert existing_summary == asr_4
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