diff --git a/python/testing/__init__.py b/python/testing/__init__.py index ba80d16405f..028f87ffbb6 100644 --- a/python/testing/__init__.py +++ b/python/testing/__init__.py @@ -73,11 +73,14 @@ class QgisTestCase(unittest.TestCase): @classmethod def setUpClass(cls): cls.report = '' + cls.markdown_report = '' @classmethod def tearDownClass(cls): if cls.report: cls.write_local_html_report(cls.report) + if cls.markdown_report: + cls.write_local_markdown_report(cls.markdown_report) @classmethod def control_path_prefix(cls) -> Optional[str]: @@ -127,6 +130,24 @@ class QgisTestCase(unittest.TestCase): if not QgisTestCase.is_ci_run(): QDesktopServices.openUrl(QUrl.fromLocalFile(report_file)) + @classmethod + def write_local_markdown_report(cls, report: str): + report_dir = QgsRenderChecker.testReportDir() + if not report_dir.exists(): + QDir().mkpath(report_dir.path()) + + report_file = report_dir.filePath('summary.md') + + # only append to existing reports if running under CI + if cls.is_ci_run() or \ + os.environ.get("QGIS_APPEND_TO_TEST_REPORT") == 'true': + file_mode = 'ta' + else: + file_mode = 'wt' + + with open(report_file, file_mode, encoding='utf-8') as f: + f.write(report) + @classmethod def image_check(cls, name: str, @@ -156,6 +177,11 @@ class QgisTestCase(unittest.TestCase): cls.report += f"