1515
1616import warnings
1717from os import getenv
18- from typing import Any , List , Optional , Tuple , Union
18+ from typing import Any , Optional , Union
1919
2020from _pytest .config import Config
2121from reportportal_client import ClientType , OutputType
@@ -50,8 +50,8 @@ class AgentConfig:
5050 rp_bts_url : str
5151 rp_launch : str
5252 rp_launch_id : Optional [str ]
53- rp_launch_attributes : Optional [List [str ]]
54- rp_tests_attributes : Optional [List [str ]]
53+ rp_launch_attributes : Optional [list [str ]]
54+ rp_tests_attributes : Optional [list [str ]]
5555 rp_launch_description : str
5656 rp_log_batch_size : int
5757 rp_log_batch_payload_limit : int
@@ -78,9 +78,12 @@ class AgentConfig:
7878 rp_launch_timeout : int
7979 rp_launch_uuid_print : bool
8080 rp_launch_uuid_print_output : Optional [OutputType ]
81- rp_http_timeout : Optional [Union [Tuple [float , float ], float ]]
81+ rp_http_timeout : Optional [Union [tuple [float , float ], float ]]
8282 rp_report_fixtures : bool
8383
84+ # Custom log levels and overrides
85+ rp_log_custom_levels : Optional [dict [int , str ]]
86+
8487 def __init__ (self , pytest_config : Config ) -> None :
8588 """Initialize required attributes."""
8689 self .rp_enabled = to_bool (getattr (pytest_config .option , "rp_enabled" , True ))
@@ -138,25 +141,8 @@ def __init__(self, pytest_config: Config) -> None:
138141 self .rp_project = self .find_option (pytest_config , "rp_project" )
139142 self .rp_rerun_of = self .find_option (pytest_config , "rp_rerun_of" )
140143
141- rp_api_retries_str = self .find_option (pytest_config , "rp_api_retries" )
142- rp_api_retries = rp_api_retries_str and int (rp_api_retries_str )
143- if rp_api_retries and rp_api_retries > 0 :
144- self .rp_api_retries = rp_api_retries
145- else :
146- rp_api_retries_str = self .find_option (pytest_config , "retries" )
147- rp_api_retries = rp_api_retries_str and int (rp_api_retries_str )
148- if rp_api_retries and rp_api_retries > 0 :
149- self .rp_api_retries = rp_api_retries
150- warnings .warn (
151- "Parameter `retries` is deprecated since 5.1.9 "
152- "and will be subject for removing in the next "
153- "major version. Use `rp_api_retries` argument "
154- "instead." ,
155- DeprecationWarning ,
156- 2 ,
157- )
158- else :
159- self .rp_api_retries = 0
144+ rp_api_retries_str = self .find_option (pytest_config , "rp_api_retries" , "0" )
145+ self .rp_api_retries = rp_api_retries_str and int (rp_api_retries_str )
160146
161147 # API key auth parameter
162148 self .rp_api_key = getenv ("RP_API_KEY" ) or self .find_option (pytest_config , "rp_api_key" )
@@ -194,6 +180,16 @@ def __init__(self, pytest_config: Config) -> None:
194180 self .rp_http_timeout = connect_timeout or read_timeout
195181 self .rp_report_fixtures = to_bool (self .find_option (pytest_config , "rp_report_fixtures" , False ))
196182
183+ # Custom log levels and overrides
184+ log_custom_levels = self .find_option (pytest_config , "rp_log_custom_levels" )
185+ self .rp_log_custom_levels = None
186+ if log_custom_levels :
187+ levels = {}
188+ for custom_level in log_custom_levels :
189+ level , level_name = str (custom_level ).split (":" , maxsplit = 1 )
190+ levels [int (level )] = level_name
191+ self .rp_log_custom_levels = levels
192+
197193 # noinspection PyMethodMayBeStatic
198194 def find_option (self , pytest_config : Config , option_name : str , default : Any = None ) -> Any :
199195 """
0 commit comments