Skip to content

Commit

Permalink
trunner: apply black corrections in test_runner.py
Browse files Browse the repository at this point in the history
JIRA: CI-375
  • Loading branch information
maska989 committed Nov 6, 2023
1 parent f6c646d commit 063e64a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions trunner/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def resolve_project_path():

class LogWrapper(StringIO):
"""Wrapper for saving all logs into StringIO and also streaming directly to stream"""

def __init__(self, stream: TextIO):
super().__init__("")
self.stream = stream
Expand Down Expand Up @@ -186,7 +187,7 @@ def _export_results_csv(self, results: Sequence[TestResult]):

fname = self.ctx.output + ".csv"

with open(fname, 'w', encoding='utf-8') as out_csv:
with open(fname, "w", encoding="utf-8") as out_csv:
out_csv.write(TestResult.get_csv_header() + "\n")
for res in results:
out_csv.write(res.to_csv() + "\n")
Expand All @@ -207,8 +208,8 @@ def _export_results_xml(self, results: Sequence[TestResult]):
suite = res.to_junit_testsuite(self.ctx.target.name)
suite.hostname = self.ctx.host.name
if is_github_actions():
suite.add_property('url', get_ci_url())
suite.add_property('SHA', os.environ['GITHUB_SHA'])
suite.add_property("url", get_ci_url())
suite.add_property("SHA", os.environ["GITHUB_SHA"])

xml.add_testsuite(suite)

Expand All @@ -221,7 +222,7 @@ def _export_results_xml(self, results: Sequence[TestResult]):
from lxml import etree
except ImportError:
from xml.etree import ElementTree as etree
with open(fname, 'wb') as out_xml:
with open(fname, "wb") as out_xml:
text = etree.tostring(xml._elem)
out_xml.write(text)

Expand Down Expand Up @@ -322,10 +323,12 @@ def run(self) -> bool:

sums = Counter(res.status for res in results)

print(f"TESTS: {len(results)} "
f"{green('PASSED')}: {sums.get(Status.OK, 0)} "
f"{red('FAILED')}: {sums.get(Status.FAIL, 0)} "
f"{yellow('SKIPPED')}: {sums.get(Status.SKIP, 0)}")
print(
f"TESTS: {len(results)} "
f"{green('PASSED')}: {sums.get(Status.OK, 0)} "
f"{red('FAILED')}: {sums.get(Status.FAIL, 0)} "
f"{yellow('SKIPPED')}: {sums.get(Status.SKIP, 0)}"
)

self._export_results_csv(results)
self._export_results_xml(results)
Expand Down

0 comments on commit 063e64a

Please sign in to comment.