From 42ae24a9591a9b2f4dddcac7eb9d4df60a311d84 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 4 Jun 2024 00:00:17 +0200 Subject: [PATCH] Fixed missing pytest post-processing tasks. --- .github/workflows/Pipeline.yml | 2 +- pyEDAA/Reports/CLI/Unittesting.py | 33 ++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index a28ca43b..8aef5775 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -166,7 +166,7 @@ jobs: - UnitTestingParams - UnitTesting with: - additional_merge_args: '--pytest "pytest.tests.unit"' + additional_merge_args: '"--pytest=reduce-depth:pytest.tests.unit"' merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} IntermediateCleanUp: diff --git a/pyEDAA/Reports/CLI/Unittesting.py b/pyEDAA/Reports/CLI/Unittesting.py index 3cc8e0f8..3a302a90 100644 --- a/pyEDAA/Reports/CLI/Unittesting.py +++ b/pyEDAA/Reports/CLI/Unittesting.py @@ -6,7 +6,8 @@ from pyTooling.Attributes.ArgParse import CommandHandler from pyTooling.Attributes.ArgParse.ValuedFlag import LongValuedFlag -from pyEDAA.Reports.Unittesting import TestsuiteKind, TestsuiteSummary, MergedTestsuiteSummary, UnittestException +from pyEDAA.Reports.Unittesting import UnittestException, TestsuiteKind, TestsuiteSummary, Testsuite, Testcase +from pyEDAA.Reports.Unittesting import MergedTestsuiteSummary from pyEDAA.Reports.Unittesting.JUnit import JUnitReaderMode @@ -45,11 +46,6 @@ def HandleUnittest(self, args: Namespace) -> None: if args.pytest is not None: self._processPyTest(result, args.pytest) - if args.output is not None: - outputs = (args.output, ) - for output in outputs: - self._output(result, output) - if args.render is not None and self.Verbose: self.WriteVerbose("*" * self.Width) @@ -59,6 +55,11 @@ def HandleUnittest(self, args: Namespace) -> None: self.WriteVerbose("*" * self.Width) + if args.output is not None: + outputs = (args.output, ) + for output in outputs: + self._output(result, output) + self.ExitOnPreviousErrors() def _merge(self, testsuiteSummary: MergedTestsuiteSummary, task: str) -> None: @@ -174,7 +175,25 @@ def _processPyTest(self, testsuiteSummary: TestsuiteSummary, cleanups: str) -> N def _processPyTest_RewiteDunderInit(self, testsuiteSummary: TestsuiteSummary): self.WriteVerbose(f" Rewriting '__init__' in classnames to actual Python package names") - self.WriteError("Rewrite __init__ not yet supported!") + + def processTestsuite(suite: Testsuite) -> None: + testsuites: Tuple[Testsuite, ...] = tuple(ts for ts in suite.Testsuites.values()) + for testsuite in testsuites: # type: Testsuite + if testsuite.Name != "__init__": + processTestsuite(testsuite) + continue + + for ts in testsuite.Testsuites.values(): # type: Testsuite + ts._parent = None + suite.AddTestsuite(ts) + + for tc in testsuite.Testcases.values(): # type: Testcase + tc._parent = None + suite.AddTestcase(tc) + + del suite._testsuites["__init__"] + + processTestsuite(testsuiteSummary) def _processPyTest_ReduceDepth(self, testsuiteSummary: TestsuiteSummary, path: str): self.WriteVerbose(f" Reducing path depth of testsuite '{path}'")