@@ -178,118 +178,112 @@ def filter_agent_calls(mock_warnings):
178178
179179
180180@mock .patch (REPORT_PORTAL_SERVICE )
181- @mock .patch (REPORT_PORTAL_PACKAGE + '.config.warnings.warn' )
182- def test_rp_api_key (mock_warnings , mock_client_init ):
181+ def test_rp_api_key (mock_client_init ):
183182 api_key = 'rp_api_key'
184183 variables = dict (utils .DEFAULT_VARIABLES )
185184 variables .update ({'rp_api_key' : api_key }.items ())
186185
187- result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
188- variables = variables )
189- assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
186+ with warnings .catch_warnings (record = True ) as w :
187+ result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
188+ variables = variables )
189+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
190190
191- expect (mock_client_init .call_count == 1 )
191+ expect (mock_client_init .call_count == 1 )
192192
193- constructor_args = mock_client_init .call_args_list [0 ][1 ]
194- expect (constructor_args ['api_key' ] == api_key )
195- agent_calls = filter_agent_calls (mock_warnings )
196- expect (len (agent_calls ) == 0 )
193+ constructor_args = mock_client_init .call_args_list [0 ][1 ]
194+ expect (constructor_args ['api_key' ] == api_key )
195+ expect (len (w ) == 0 )
197196 assert_expectations ()
198197
199198
200199@mock .patch (REPORT_PORTAL_SERVICE )
201- @mock .patch (REPORT_PORTAL_PACKAGE + '.config.warnings.warn' )
202- def test_rp_uuid (mock_warnings , mock_client_init ):
200+ def test_rp_uuid (mock_client_init ):
203201 api_key = 'rp_api_key'
204202 variables = dict (utils .DEFAULT_VARIABLES )
205203 del variables ['rp_api_key' ]
206204 variables .update ({'rp_uuid' : api_key }.items ())
207205
208- result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
209- variables = variables )
210- assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
206+ with warnings .catch_warnings (record = True ) as w :
207+ result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
208+ variables = variables )
209+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
211210
212- expect (mock_client_init .call_count == 1 )
211+ expect (mock_client_init .call_count == 1 )
213212
214- constructor_args = mock_client_init .call_args_list [0 ][1 ]
215- expect (constructor_args ['api_key' ] == api_key )
216- agent_calls = filter_agent_calls (mock_warnings )
217- expect (len (agent_calls ) == 1 )
213+ constructor_args = mock_client_init .call_args_list [0 ][1 ]
214+ expect (constructor_args ['api_key' ] == api_key )
215+ expect (len (w ) == 1 )
218216 assert_expectations ()
219217
220218
221219@mock .patch (REPORT_PORTAL_SERVICE )
222- @mock .patch (REPORT_PORTAL_PACKAGE + '.config.warnings.warn' )
223- def test_rp_api_key_priority (mock_warnings , mock_client_init ):
220+ def test_rp_api_key_priority (mock_client_init ):
224221 api_key = 'rp_api_key'
225222 variables = dict (utils .DEFAULT_VARIABLES )
226223 variables .update ({'rp_api_key' : api_key , 'rp_uuid' : 'rp_uuid' }.items ())
227224
228- result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
229- variables = variables )
230- assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
225+ with warnings .catch_warnings (record = True ) as w :
226+ result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
227+ variables = variables )
228+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
231229
232- expect (mock_client_init .call_count == 1 )
230+ expect (mock_client_init .call_count == 1 )
233231
234- constructor_args = mock_client_init .call_args_list [0 ][1 ]
235- expect (constructor_args ['api_key' ] == api_key )
236- agent_calls = filter_agent_calls (mock_warnings )
237- expect (len (agent_calls ) == 0 )
232+ constructor_args = mock_client_init .call_args_list [0 ][1 ]
233+ expect (constructor_args ['api_key' ] == api_key )
234+ expect (len (w ) == 0 )
238235 assert_expectations ()
239236
240237
241238@mock .patch (REPORT_PORTAL_SERVICE )
242- @mock .patch (REPORT_PORTAL_PACKAGE + '.config.warnings.warn' )
243- def test_rp_api_key_empty (mock_warnings , mock_client_init ):
239+ def test_rp_api_key_empty (mock_client_init ):
244240 api_key = ''
245241 variables = dict (utils .DEFAULT_VARIABLES )
246242 variables .update ({'rp_api_key' : api_key }.items ())
247243
248- result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
249- variables = variables )
250- assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
244+ with warnings .catch_warnings (record = True ) as w :
245+ result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
246+ variables = variables )
247+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
251248
252- expect (mock_client_init .call_count == 0 )
253- agent_calls = filter_agent_calls (mock_warnings )
254- expect (len (agent_calls ) == 1 )
249+ expect (mock_client_init .call_count == 0 )
250+ expect (len (w ) == 1 )
255251 assert_expectations ()
256252
257253
258254@mock .patch (REPORT_PORTAL_SERVICE )
259- @mock .patch (REPORT_PORTAL_PACKAGE + '.config.warnings.warn' )
260- def test_rp_api_retries (mock_warnings , mock_client_init ):
255+ def test_rp_api_retries (mock_client_init ):
261256 retries = 5
262257 variables = dict (utils .DEFAULT_VARIABLES )
263258 variables .update ({'rp_api_retries' : str (retries )}.items ())
264259
265- result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
266- variables = variables )
267- assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
260+ with warnings .catch_warnings (record = True ) as w :
261+ result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
262+ variables = variables )
263+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
268264
269- expect (mock_client_init .call_count == 1 )
265+ expect (mock_client_init .call_count == 1 )
270266
271- constructor_args = mock_client_init .call_args_list [0 ][1 ]
272- expect (constructor_args ['retries' ] == retries )
273- agent_calls = filter_agent_calls (mock_warnings )
274- expect (len (agent_calls ) == 0 )
267+ constructor_args = mock_client_init .call_args_list [0 ][1 ]
268+ expect (constructor_args ['retries' ] == retries )
269+ expect (len (w ) == 0 )
275270 assert_expectations ()
276271
277272
278273@mock .patch (REPORT_PORTAL_SERVICE )
279- @mock .patch (REPORT_PORTAL_PACKAGE + '.config.warnings.warn' )
280- def test_retries (mock_warnings , mock_client_init ):
274+ def test_retries (mock_client_init ):
281275 retries = 5
282276 variables = utils .DEFAULT_VARIABLES .copy ()
283277 variables .update ({'retries' : str (retries )}.items ())
284278
285- result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
286- variables = variables )
287- assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
279+ with warnings .catch_warnings (record = True ) as w :
280+ result = utils .run_pytest_tests (['examples/test_rp_logging.py' ],
281+ variables = variables )
282+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
288283
289- expect (mock_client_init .call_count == 1 )
284+ expect (mock_client_init .call_count == 1 )
290285
291- constructor_args = mock_client_init .call_args_list [0 ][1 ]
292- expect (constructor_args ['retries' ] == retries )
293- agent_calls = filter_agent_calls (mock_warnings )
294- expect (len (agent_calls ) == 1 )
286+ constructor_args = mock_client_init .call_args_list [0 ][1 ]
287+ expect (constructor_args ['retries' ] == retries )
288+ expect (len (w ) == 1 )
295289 assert_expectations ()
0 commit comments