Skip to content

Commit

Permalink
Rename Testcase and Testsuite to Test and Testrun
Browse files Browse the repository at this point in the history
Signed-off-by: joseph-sentry <[email protected]>
  • Loading branch information
joseph-sentry committed Oct 23, 2023
1 parent 7246a9d commit d527849
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions codecov_cli/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions codecov_cli/parsers/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")

Check warning on line 19 in codecov_cli/parsers/junit.py

View check run for this annotation

Codecov / codecov/patch

codecov_cli/parsers/junit.py#L19

Added line #L19 was not covered by tests
Expand All @@ -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"))),
Expand Down
6 changes: 3 additions & 3 deletions tests/parsers/test_base.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 0 additions & 1 deletion tests/parsers/test_junit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from datetime import datetime, timedelta

from codecov_cli.parsers.base import Testcase, Testsuite
from codecov_cli.parsers.junit import JUnitXMLParser


Expand Down

0 comments on commit d527849

Please sign in to comment.