@@ -157,22 +157,18 @@ def test_rp_log_batch_payload_size(mock_client_init):
157157 assert_expectations ()
158158
159159
160- def filter_agent_call (args ):
161- if len (args [0 ]) > 1 and args [0 ][1 ]:
162- return args [0 ][1 ].__name__ == 'DeprecationWarning' \
163- or args [0 ][1 ].__name__ == 'RuntimeWarning'
164- else :
165- if 'category' in args [1 ] and args [1 ]['category' ]:
166- return args [1 ]['category' ].__name__ == 'DeprecationWarning' \
167- or args [1 ]['category' ].__name__ == 'RuntimeWarning'
160+ def filter_agent_call (warn ):
161+ category = getattr (warn , 'category' , None )
162+ if category :
163+ return category .__name__ != 'PytestAssertRewriteWarning'
168164 return False
169165
170166
171- def filter_agent_calls (mock_warnings ):
167+ def filter_agent_calls (warning_list ):
172168 return list (
173169 filter (
174170 lambda call : filter_agent_call (call ),
175- mock_warnings . call_args_list
171+ warning_list
176172 )
177173 )
178174
@@ -192,7 +188,7 @@ def test_rp_api_key(mock_client_init):
192188
193189 constructor_args = mock_client_init .call_args_list [0 ][1 ]
194190 expect (constructor_args ['api_key' ] == api_key )
195- expect (len (w ) == 0 )
191+ expect (len (filter_agent_calls ( w ) ) == 0 )
196192 assert_expectations ()
197193
198194
@@ -212,7 +208,7 @@ def test_rp_uuid(mock_client_init):
212208
213209 constructor_args = mock_client_init .call_args_list [0 ][1 ]
214210 expect (constructor_args ['api_key' ] == api_key )
215- expect (len (w ) == 1 )
211+ expect (len (filter_agent_calls ( w ) ) == 1 )
216212 assert_expectations ()
217213
218214
@@ -231,7 +227,7 @@ def test_rp_api_key_priority(mock_client_init):
231227
232228 constructor_args = mock_client_init .call_args_list [0 ][1 ]
233229 expect (constructor_args ['api_key' ] == api_key )
234- expect (len (w ) == 0 )
230+ expect (len (filter_agent_calls ( w ) ) == 0 )
235231 assert_expectations ()
236232
237233
@@ -247,7 +243,7 @@ def test_rp_api_key_empty(mock_client_init):
247243 assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
248244
249245 expect (mock_client_init .call_count == 0 )
250- expect (len (w ) == 1 )
246+ expect (len (filter_agent_calls ( w ) ) == 1 )
251247 assert_expectations ()
252248
253249
@@ -266,7 +262,7 @@ def test_rp_api_retries(mock_client_init):
266262
267263 constructor_args = mock_client_init .call_args_list [0 ][1 ]
268264 expect (constructor_args ['retries' ] == retries )
269- expect (len (w ) == 0 )
265+ expect (len (filter_agent_calls ( w ) ) == 0 )
270266 assert_expectations ()
271267
272268
@@ -285,5 +281,5 @@ def test_retries(mock_client_init):
285281
286282 constructor_args = mock_client_init .call_args_list [0 ][1 ]
287283 expect (constructor_args ['retries' ] == retries )
288- expect (len (w ) == 1 )
284+ expect (len (filter_agent_calls ( w ) ) == 1 )
289285 assert_expectations ()
0 commit comments