Skip to content

Commit

Permalink
Updated unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Feb 21, 2024
1 parent bf77d8e commit a9aa250
Show file tree
Hide file tree
Showing 11 changed files with 3,209 additions and 310 deletions.
114 changes: 0 additions & 114 deletions pyEDAA/Reports/Testcases/OSVVM.py

This file was deleted.

154 changes: 0 additions & 154 deletions pyEDAA/Reports/Testcases/__init__.py

This file was deleted.

20 changes: 20 additions & 0 deletions pyEDAA/Reports/Unittesting/JUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from pyTooling.MetaClasses import ExtendedType

from pyEDAA.Reports.Unittesting import UnittestException, DuplicateTestsuiteException, DuplicateTestcaseException
from pyEDAA.Reports.Unittesting import Testsuite as gen_Testsuite, Testcase as gen_Testcase


@export
Expand Down Expand Up @@ -290,6 +291,25 @@ def Aggregate(self) -> Tuple[int, int, int, int, int]:

return tests, skipped, errored, failed, passed

def ConvertToGeneric(self) -> gen_Testsuite:
def convertTestsuite(testsuite: Testsuite) -> gen_Testsuite:
newTestsuite = gen_Testsuite(testsuite._name)

for testsuite in testsuite._testsuites.values():
newTestsuite.AddTestsuite(convertTestsuite(testsuite))

for testcase in testsuite._testcases.values():
newTestsuite.AddTestcase(gen_Testcase(testcase._name))

return newTestsuite

rootTS = gen_Testsuite(self._name)

for testsuite in self._testsuites.values():
rootTS.AddTestsuite(convertTestsuite(testsuite))

return rootTS


@export
class Document(TestsuiteSummary):
Expand Down
4 changes: 2 additions & 2 deletions pyEDAA/Reports/Unittesting/OSVVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Document:
_yamlDocument: YAML
_testsuites: Dict[str, Testsuite]

def __init__(self, yamlReportFile: Path):
def __init__(self, yamlReportFile: Path) -> None:
yamlReader = YAML()
self._yamlDocument = yamlReader.load(yamlReportFile)
yamlBuild = self._yamlDocument["Build"]
Expand All @@ -62,7 +62,7 @@ def __init__(self, yamlReportFile: Path):

self.translateDocument()

def translateDocument(self):
def translateDocument(self) -> None:
for yamlTestsuite in self._yamlDocument['TestSuites']:
name = yamlTestsuite["Name"]
self._testsuites[name] = self.translateTestsuite(yamlTestsuite, name)
Expand Down
10 changes: 5 additions & 5 deletions pyEDAA/Reports/Unittesting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def Aggregate(self) -> None:
for testcase in self._testcases.values():
testcase.Aggregate()

def AddTestsuite(self, testsuite: "Testsuite"):
def AddTestsuite(self, testsuite: "Testsuite") -> None:
if testsuite._parent is not None:
raise ValueError(f"Testsuite '{testsuite._name}' is already part of a testsuite hierarchy.")

Expand All @@ -200,11 +200,11 @@ def AddTestsuite(self, testsuite: "Testsuite"):
testsuite._parent = self
self._testsuites[testsuite._name] = testsuite

def AddTestsuites(self, testsuites: Iterable["Testsuite"]):
def AddTestsuites(self, testsuites: Iterable["Testsuite"]) -> None:
for testsuite in testsuites:
self.AddTestsuite(testsuite)

def AddTestcase(self, testcase: "Testcase"):
def AddTestcase(self, testcase: "Testcase") -> None:
if testcase._parent is not None:
raise ValueError(f"Testcase '{testcase._name}' is already part of a testsuite hierarchy.")

Expand All @@ -214,7 +214,7 @@ def AddTestcase(self, testcase: "Testcase"):
testcase._parent = self
self._testcases[testcase._name] = testcase

def AddTestcases(self, testcases: Iterable["Testcase"]):
def AddTestcases(self, testcases: Iterable["Testcase"]) -> None:
for testcase in testcases:
self.AddTestcase(testcase)

Expand Down Expand Up @@ -315,5 +315,5 @@ def ErrorCount(self) -> int:
def FatalCount(self) -> int:
return self._fatalCount

def Aggregate(self):
def Aggregate(self) -> None:
pass
3 changes: 2 additions & 1 deletion pyEDAA/Reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@
from pyTooling.Decorators import export


@export
class ReportException(Exception):

# WORKAROUND: for Python <3.11
# Implementing a dummy method for Python versions before
__notes__: List[str]
if version_info < (3, 11): # pragma: no cover
def add_note(self, message: str):
def add_note(self, message: str) -> None:
try:
self.__notes__.append(message)
except AttributeError:
Expand Down
Loading

0 comments on commit a9aa250

Please sign in to comment.