Skip to content

Commit

Permalink
Handle multiple pytest cleanup rules at once.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed May 5, 2024
1 parent 22ed26a commit 5e5a024
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
51 changes: 36 additions & 15 deletions pyEDAA/Reports/CLI/Unittesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,42 @@ def HandleMergeUnittest(self, args: Namespace) -> None:
result = merged.ToTestsuiteSummary()

if args.pytest is not None:
self.WriteNormal(f"Remove overhead from pytest ...")
suite = result

for element in args.pytest.split("."):
suite = suite._testsuites[element]

for ts in suite._testsuites.values():
ts._parent = None
ts._kind = TestsuiteKind.Logical
result.AddTestsuite(ts)

while suite is not result:
name = suite._name
suite = suite._parent
del suite._testsuites[name]
self.WriteNormal(f"Simplifying unit testing reports created by pytest ...")

cleanups = []
for path in args.pytest.split(";"):
suite = result
message = f" Walking: {suite._name}"
for element in path.split("."):
if element in suite._testsuites:
suite = suite._testsuites[element]
message += f" -> {suite._name}"
else:
self.WriteVerbose(f" Skipping: {path}")
suite = None
break

if suite is None:
continue

self.WriteVerbose(message)
cleanups.append(suite)

self.WriteVerbose(f" Moving testsuites ...")
for ts in suite._testsuites.values():
self.WriteDebug(f" {ts._name} -> {result._name}")
ts._parent = None
ts._kind = TestsuiteKind.Logical
result.AddTestsuite(ts)

self.WriteVerbose(f" Deleting empty testsuites ...")
for clean in cleanups:
suite = clean
while suite is not result:
name = suite._name
suite = suite._parent
self.WriteDebug(f" {name}")
del suite._testsuites[name]

self.WriteNormal(f"Writing merged unit test summaries to file ...")
mergedFile = Path.cwd() / Path("Unittesting.xml")
Expand Down
2 changes: 1 addition & 1 deletion pyEDAA/Reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
__email__ = "Paebbels@gmail.com"
__copyright__ = "2021-2024, Electronic Design Automation Abstraction (EDA²)"
__license__ = "Apache License, Version 2.0"
__version__ = "0.7.0"
__version__ = "0.7.1"
__keywords__ = ["Reports", "Abstract Model", "Data Model", "Unit Testing", "Testcase", "Testsuite", "OSVVM", "YAML", "XML"]

from enum import Enum
Expand Down

0 comments on commit 5e5a024

Please sign in to comment.