From d527849fe058e081e07bdf9cc99678df9011b23a Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Mon, 23 Oct 2023 10:31:38 -0400 Subject: [PATCH] Rename Testcase and Testsuite to Test and Testrun Signed-off-by: joseph-sentry --- codecov_cli/parsers/base.py | 6 +++--- codecov_cli/parsers/junit.py | 8 ++++---- tests/parsers/test_base.py | 6 +++--- tests/parsers/test_junit.py | 1 - 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/codecov_cli/parsers/base.py b/codecov_cli/parsers/base.py index 86000944..9921fcf6 100644 --- a/codecov_cli/parsers/base.py +++ b/codecov_cli/parsers/base.py @@ -6,7 +6,7 @@ class ParsingError(Exception): ... -class Testcase(object): +class Test(object): def __init__(self, name: str, status: bool, duration: timedelta): self.name = name self.status = status @@ -16,13 +16,13 @@ def __repr__(self): return f"{self.name}:{self.status}:{self.duration.total_seconds()}::" -class Testsuite(object): +class Testrun(object): def __init__( self, name: str, timestamp: datetime, time: timedelta, - testcases: List[Testcase], + testcases: List[Test], failures: int, errors: int, skipped: int, diff --git a/codecov_cli/parsers/junit.py b/codecov_cli/parsers/junit.py index 16c4a101..cbf0a497 100644 --- a/codecov_cli/parsers/junit.py +++ b/codecov_cli/parsers/junit.py @@ -4,7 +4,7 @@ from lxml import etree -from codecov_cli.parsers.base import ParsingError, Testcase, Testsuite +from codecov_cli.parsers.base import ParsingError, Test, Testrun logger = logging.getLogger("codecovcli") @@ -13,7 +13,7 @@ class JUnitXMLParser: def __init__(self): self._parser = etree.XMLParser(recover=True, resolve_entities=False) - def parse(self, file_content) -> List[Testsuite]: + def parse(self, file_content) -> List[Testrun]: processed = self._parse_xml(file_content) if processed is None or len(processed) == 0: raise ParsingError("Error parsing XML file") @@ -26,14 +26,14 @@ def parse(self, file_content) -> List[Testsuite]: return testsuites def _create_testcase(self, testcase_xml: etree.Element): - return Testcase( + return Test( f"{testcase_xml.get('classname')}.{testcase_xml.get('name')}", len(testcase_xml) == 0, timedelta(seconds=float(testcase_xml.get("time"))), ) def _create_testsuite(self, testsuite_xml: etree.Element): - return Testsuite( + return Testrun( testsuite_xml.get("name"), datetime.fromisoformat(testsuite_xml.get("timestamp")), timedelta(seconds=float(testsuite_xml.get("time"))), diff --git a/tests/parsers/test_base.py b/tests/parsers/test_base.py index 48353fff..b03be052 100644 --- a/tests/parsers/test_base.py +++ b/tests/parsers/test_base.py @@ -1,15 +1,15 @@ from datetime import datetime, timedelta -from codecov_cli.parsers.base import Testcase, Testsuite +from codecov_cli.parsers.base import Test, Testrun def test_testsuite(): now = datetime.now() - ts = Testsuite( + ts = Testrun( "test_name", now, timedelta(seconds=1), - [Testcase("testcase_name", True, timedelta(seconds=1))], + [Test("testcase_name", True, timedelta(seconds=1))], errors=0, failures=0, skipped=0, diff --git a/tests/parsers/test_junit.py b/tests/parsers/test_junit.py index d1386781..20bb3727 100644 --- a/tests/parsers/test_junit.py +++ b/tests/parsers/test_junit.py @@ -1,6 +1,5 @@ from datetime import datetime, timedelta -from codecov_cli.parsers.base import Testcase, Testsuite from codecov_cli.parsers.junit import JUnitXMLParser