Skip to content

Commit 172dca7

Browse files
committed
Add some type hinting
1 parent 21b321d commit 172dca7

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

pytest_reportportal/service.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pytest import Class, Function, Module, Package, Item, Session, PytestWarning
2828
from reportportal_client.aio import Task
2929
from reportportal_client.core.rp_issues import Issue, ExternalIssue
30+
from reportportal_client.helpers import timestamp
3031

3132
from .config import AgentConfig
3233

@@ -54,19 +55,13 @@
5455
MAX_ITEM_NAME_LENGTH: int = 256
5556
TRUNCATION_STR: str = '...'
5657
ROOT_DIR: str = str(os.path.abspath(curdir))
57-
PYTEST_MARKS_IGNORE: Set[str] = {'parametrize', 'usefixtures',
58-
'filterwarnings'}
58+
PYTEST_MARKS_IGNORE: Set[str] = {'parametrize', 'usefixtures', 'filterwarnings'}
5959
NOT_ISSUE: Issue = Issue('NOT_ISSUE')
6060
ISSUE_DESCRIPTION_LINE_TEMPLATE: str = '* {}:{}'
6161
ISSUE_DESCRIPTION_URL_TEMPLATE: str = ' [{issue_id}]({url})'
6262
ISSUE_DESCRIPTION_ID_TEMPLATE: str = ' {issue_id}'
6363

6464

65-
def timestamp():
66-
"""Time for difference between start and finish tests."""
67-
return str(int(time() * 1000))
68-
69-
7065
def trim_docstring(docstring: str) -> str:
7166
"""
7267
Convert docstring.
@@ -102,7 +97,6 @@ def trim_docstring(docstring: str) -> str:
10297
@unique
10398
class LeafType(Enum):
10499
"""This class stores test item path types."""
105-
106100
DIR = auto()
107101
CODE = auto()
108102
ROOT = auto()
@@ -111,7 +105,6 @@ class LeafType(Enum):
111105
@unique
112106
class ExecStatus(Enum):
113107
"""This class stores test item path types."""
114-
115108
CREATED = auto()
116109
IN_PROGRESS = auto()
117110
FINISHED = auto()
@@ -125,7 +118,7 @@ def wrap(*args, **kwargs):
125118
if args and isinstance(args[0], PyTestServiceClass):
126119
if not args[0].rp:
127120
return
128-
func(*args, **kwargs)
121+
return func(*args, **kwargs)
129122

130123
return wrap
131124

@@ -176,7 +169,7 @@ def issue_types(self) -> Dict[str, str]:
176169
self._issue_types[item["shortName"]] = item["locator"]
177170
return self._issue_types
178171

179-
def _get_launch_attributes(self, ini_attrs):
172+
def _get_launch_attributes(self, ini_attrs: Optional[List[Dict[str, str]]]) -> List[Dict[str, str]]:
180173
"""Generate launch attributes in the format supported by the client.
181174
182175
:param list ini_attrs: List for attributes from the pytest.ini file
@@ -187,7 +180,7 @@ def _get_launch_attributes(self, ini_attrs):
187180
'{}|{}'.format(self.agent_name, self.agent_version))
188181
return attributes + dict_to_payload(system_attributes)
189182

190-
def _build_start_launch_rq(self):
183+
def _build_start_launch_rq(self) -> Dict[str, Any]:
191184
rp_launch_attributes = self._config.rp_launch_attributes
192185
attributes = gen_attributes(rp_launch_attributes) if rp_launch_attributes else None
193186

0 commit comments

Comments
 (0)