Skip to content

Commit d00830a

Browse files
author
frizzby
committed
Improved code formatting. Some corner cases are now handled correctly.
Mandatory api arguments are no longer defined as optional in service class methods.
1 parent 3e11651 commit d00830a

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

pytest_reportportal/service.py

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ def start_launch(
4747
self, launch_name=None, mode=None, tags=None, launch=None):
4848
# In next versions launch object(suite, testcase)
4949
# could be set as parameter
50-
sl_pt = dict(
51-
name=launch_name,
52-
start_time=timestamp(),
53-
description='Pytest Launch',
54-
mode=mode,
55-
tags=tags)
50+
sl_pt = {
51+
"name": launch_name,
52+
"start_time": timestamp(),
53+
"description": 'Pytest Launch',
54+
"mode": mode,
55+
"tags": tags
56+
}
5657
logging.debug("ReportPortal - Start launch: "
5758
"request_body={0}".format(sl_pt))
5859
req_data = self.RP.start_launch(**sl_pt)
@@ -64,47 +65,56 @@ def start_pytest_item(self, test_item=None):
6465
# for common items
6566
item_description = test_item.function.__doc__
6667
except AttributeError:
67-
# doctest has no `function` attribute
68+
# doctest has no `function` attribute
6869
item_description = test_item.reportinfo()[2]
69-
start_rq = dict(
70-
name=test_item.name,
71-
description=item_description,
72-
tags=['PyTest Item Tag'],
73-
start_time=timestamp(),
74-
type="TEST")
70+
start_rq = {
71+
"name": test_item.name,
72+
"description": item_description,
73+
"tags": ['PyTest Item Tag'],
74+
"start_time": timestamp(),
75+
"item_type": "TEST"
76+
}
7577

7678
logging.debug(
7779
"ReportPortal - Start TestItem: "
78-
"request_body={0}".format(start_rq))
80+
"request_body=%s", start_rq)
7981

8082
self.RP.start_test_item(**start_rq)
8183

8284
def finish_pytest_item(self, status, issue=None):
83-
fta_rq = dict(end_time=timestamp(),
84-
status=status,
85-
issue=issue)
85+
fta_rq = {
86+
"end_time": timestamp(),
87+
"status": status,
88+
"issue": issue
89+
}
8690

8791
logging.debug(
8892
"ReportPortal - Finish TestItem:"
89-
" request_body={0}".format(fta_rq))
93+
" request_body=%s", fta_rq)
9094
self.RP.finish_test_item(**fta_rq)
9195

9296
def finish_launch(self, launch=None, status="rp_launch"):
9397
# TO finish launch session str parameter is needed
94-
fl_rq = dict(
95-
end_time=timestamp(),
96-
status=status)
97-
logging.debug(msg="ReportPortal - Finish launch: "
98-
"request_body={0}".format(fl_rq))
98+
fl_rq = {
99+
"end_time": timestamp(),
100+
"status": status
101+
}
102+
logging.debug("ReportPortal - Finish launch: "
103+
"request_body=%s", fl_rq)
99104
self.RP.finish_launch(**fl_rq)
100105

101106
def post_log(self, message, loglevel='INFO'):
102107
if loglevel not in self._loglevels:
103-
logging.warning('Incorrect loglevel = {}. Force set to INFO. Avaliable levels: '
104-
'{}.'.format(loglevel, self._loglevels))
108+
logging.warning(
109+
'Incorrect loglevel = %s. Force set to INFO. Avaliable levels:'
110+
' %s.', loglevel, self._loglevels)
105111
loglevel = 'INFO'
106112

107-
sl_rq = dict(time=timestamp(), message=message, level=loglevel)
113+
sl_rq = {
114+
"time": timestamp(),
115+
"message": message,
116+
"level": loglevel
117+
}
108118
self.RP.log(**sl_rq)
109119

110120

0 commit comments

Comments
 (0)