7474except ImportError :
7575 Rule = type ("dummy" , (), {}) # Old pytest-bdd versions do not have Rule
7676
77- from reportportal_client import RP , ClientType , create_client
77+ from reportportal_client import RP , OutputType , create_client
7878from reportportal_client .helpers import dict_to_payload , gen_attributes , get_launch_sys_attrs , get_package_version
7979
8080LOGGER = logging .getLogger (__name__ )
@@ -188,7 +188,7 @@ def __init__(self, agent_config: AgentConfig) -> None:
188188 self ._start_tracker = set ()
189189 self ._launch_id = None
190190 self .agent_name = "pytest-reportportal"
191- self .agent_version = get_package_version (self .agent_name )
191+ self .agent_version = get_package_version (self .agent_name ) or "None"
192192 self .ignored_attributes = []
193193 self .parent_item_id = None
194194 self .rp = None
@@ -219,7 +219,7 @@ def _get_launch_attributes(self, ini_attrs: Optional[list[dict[str, str]]]) -> l
219219 attributes = ini_attrs or []
220220 system_attributes = get_launch_sys_attrs ()
221221 system_attributes ["agent" ] = "{}|{}" .format (self .agent_name , self .agent_version )
222- return attributes + dict_to_payload (system_attributes )
222+ return attributes + ( dict_to_payload (system_attributes ) or [] )
223223
224224 def _build_start_launch_rq (self ) -> dict [str , Any ]:
225225 rp_launch_attributes = self ._config .rp_launch_attributes
@@ -364,6 +364,7 @@ def _get_scenario_template(self, scenario: Scenario) -> Optional[ScenarioTemplat
364364 break
365365 if scenario_template and isinstance (scenario_template , ScenarioTemplate ):
366366 return scenario_template
367+ return None
367368
368369 def _get_method_name (self , item : Item ) -> str :
369370 """Get the original test method name.
@@ -648,20 +649,20 @@ def _get_test_case_id(
648649 else :
649650 return base_name + param_str
650651
651- def _get_issue_ids (self , mark ):
652- issue_ids = mark .kwargs .get ("issue_id" , [])
652+ def _get_issue_ids (self , mark ) -> list [ Any ] :
653+ issue_ids = mark .kwargs .get ("issue_id" , []) or []
653654 if not isinstance (issue_ids , list ):
654655 issue_ids = [issue_ids ]
655656 return issue_ids
656657
657- def _get_issue_urls (self , mark , default_url ) :
658+ def _get_issue_urls (self , mark , default_url : str ) -> list [ Optional [ str ]] :
658659 issue_ids = self ._get_issue_ids (mark )
659660 if not issue_ids :
660- return None
661+ return []
661662 mark_url = mark .kwargs .get ("url" , None ) or default_url
662- return [mark_url .format (issue_id = issue_id ) if mark_url else None for issue_id in issue_ids ]
663+ return [str ( mark_url ) .format (issue_id = str ( issue_id ) ) if mark_url else None for issue_id in issue_ids ]
663664
664- def _get_issue_description_line (self , mark , default_url ) :
665+ def _get_issue_description_line (self , mark , default_url : str ) -> str :
665666 issue_ids = self ._get_issue_ids (mark )
666667 if not issue_ids :
667668 return mark .kwargs ["reason" ]
@@ -691,7 +692,7 @@ def _get_issue(self, mark: Mark) -> Optional[Issue]:
691692 issue_short_name = mark .kwargs ["issue_type" ]
692693
693694 # default value
694- issue_short_name = "TI" if issue_short_name is None else issue_short_name
695+ issue_short_name = "TI" if issue_short_name is None else str ( issue_short_name )
695696
696697 registered_issues = self .issue_types
697698 issue = None
@@ -822,7 +823,8 @@ def _process_attributes(self, item: Item) -> list[dict[str, Any]]:
822823 test_attributes = self ._config .rp_tests_attributes
823824 if test_attributes :
824825 attributes = {
825- (attr .get ("key" , None ), attr ["value" ]) for attr in gen_attributes (self ._config .rp_tests_attributes )
826+ (attr .get ("key" , None ), attr ["value" ])
827+ for attr in gen_attributes (self ._config .rp_tests_attributes or [])
826828 }
827829 else :
828830 attributes = set ()
@@ -1418,7 +1420,7 @@ def start(self) -> None:
14181420 if self ._config .rp_launch_uuid :
14191421 launch_id = self ._config .rp_launch_uuid
14201422 self .rp = create_client (
1421- client_type = self ._config .rp_client_type or ClientType . SYNC ,
1423+ client_type = self ._config .rp_client_type ,
14221424 endpoint = self ._config .rp_endpoint ,
14231425 project = self ._config .rp_project ,
14241426 api_key = self ._config .rp_api_key ,
@@ -1429,7 +1431,7 @@ def start(self) -> None:
14291431 launch_uuid = launch_id ,
14301432 log_batch_payload_limit = self ._config .rp_log_batch_payload_limit ,
14311433 launch_uuid_print = self ._config .rp_launch_uuid_print ,
1432- print_output = self ._config .rp_launch_uuid_print_output ,
1434+ print_output = self ._config .rp_launch_uuid_print_output or OutputType . STDOUT ,
14331435 http_timeout = self ._config .rp_http_timeout ,
14341436 mode = self ._config .rp_mode ,
14351437 # OAuth 2.0 parameters
0 commit comments