@@ -242,7 +242,8 @@ def test_wrap_requests_timeout(self):
242242 url = 'http://localhost:8080/test'
243243
244244 with patch , patch_thread :
245- wrapped (url )
245+ with self .assertRaises (requests .Timeout ):
246+ wrapped (url )
246247
247248 expected_attributes = {
248249 'http.host' : 'localhost:8080' ,
@@ -288,7 +289,8 @@ def test_wrap_requests_invalid_url(self):
288289 url = 'http://localhost:8080/test'
289290
290291 with patch , patch_thread :
291- wrapped (url )
292+ with self .assertRaises (requests .URLRequired ):
293+ wrapped (url )
292294
293295 expected_attributes = {
294296 'http.host' : 'localhost:8080' ,
@@ -308,6 +310,7 @@ def test_wrap_requests_invalid_url(self):
308310 expected_status .__dict__ ,
309311 mock_tracer .current_span .status .__dict__
310312 )
313+ self .assertRaises (requests .URLRequired , mock_func )
311314
312315 def test_wrap_requests_exception (self ):
313316 mock_return = mock .Mock ()
@@ -334,7 +337,8 @@ def test_wrap_requests_exception(self):
334337 url = 'http://localhost:8080/test'
335338
336339 with patch , patch_thread :
337- wrapped (url )
340+ with self .assertRaises (requests .TooManyRedirects ):
341+ wrapped (url )
338342
339343 expected_attributes = {
340344 'http.host' : 'localhost:8080' ,
@@ -354,6 +358,7 @@ def test_wrap_requests_exception(self):
354358 expected_status .__dict__ ,
355359 mock_tracer .current_span .status .__dict__
356360 )
361+ self .assertRaises (requests .TooManyRedirects , mock_func )
357362
358363 def test_wrap_session_request (self ):
359364 wrapped = mock .Mock (return_value = mock .Mock (status_code = 200 ))
@@ -376,8 +381,10 @@ def test_wrap_session_request(self):
376381 kwargs = {}
377382
378383 with patch , patch_thread :
379- trace .wrap_session_request (wrapped , 'Session.request' ,
380- (request_method , url ), kwargs )
384+ trace .wrap_session_request (
385+ wrapped , 'Session.request' ,
386+ (request_method , url ), kwargs
387+ )
381388
382389 expected_attributes = {
383390 'http.host' : 'localhost:8080' ,
@@ -427,8 +434,10 @@ def wrapped(*args, **kwargs):
427434 request_method = 'POST'
428435
429436 with patch_tracer , patch_attr , patch_thread :
430- trace .wrap_session_request (wrapped , 'Session.request' ,
431- (request_method , url ), {})
437+ trace .wrap_session_request (
438+ wrapped , 'Session.request' ,
439+ (request_method , url ), {}
440+ )
432441
433442 expected_name = '/'
434443 self .assertEqual (expected_name , mock_tracer .current_span .name )
@@ -458,8 +467,11 @@ def wrapped(*args, **kwargs):
458467 request_method = 'POST'
459468
460469 with patch_tracer , patch_attr , patch_thread :
461- trace .wrap_session_request (wrapped , 'Session.request' ,
462- (request_method , url ), {})
470+ trace .wrap_session_request (
471+ wrapped , 'Session.request' ,
472+ (request_method , url ), {}
473+ )
474+
463475 self .assertEqual (None , mock_tracer .current_span )
464476
465477 def test_wrap_session_request_exporter_thread (self ):
@@ -487,8 +499,11 @@ def wrapped(*args, **kwargs):
487499 request_method = 'POST'
488500
489501 with patch_tracer , patch_attr , patch_thread :
490- trace .wrap_session_request (wrapped , 'Session.request' ,
491- (request_method , url ), {})
502+ trace .wrap_session_request (
503+ wrapped , 'Session.request' ,
504+ (request_method , url ), {}
505+ )
506+
492507 self .assertEqual (None , mock_tracer .current_span )
493508
494509 def test_header_is_passed_in (self ):
@@ -511,8 +526,10 @@ def test_header_is_passed_in(self):
511526 kwargs = {}
512527
513528 with patch , patch_thread :
514- trace .wrap_session_request (wrapped , 'Session.request' ,
515- (request_method , url ), kwargs )
529+ trace .wrap_session_request (
530+ wrapped , 'Session.request' ,
531+ (request_method , url ), kwargs
532+ )
516533
517534 self .assertEqual (kwargs ['headers' ]['x-trace' ], 'some-value' )
518535
@@ -536,8 +553,10 @@ def test_headers_are_preserved(self):
536553 kwargs = {'headers' : {'key' : 'value' }}
537554
538555 with patch , patch_thread :
539- trace .wrap_session_request (wrapped , 'Session.request' ,
540- (request_method , url ), kwargs )
556+ trace .wrap_session_request (
557+ wrapped , 'Session.request' ,
558+ (request_method , url ), kwargs
559+ )
541560
542561 self .assertEqual (kwargs ['headers' ]['key' ], 'value' )
543562 self .assertEqual (kwargs ['headers' ]['x-trace' ], 'some-value' )
@@ -563,8 +582,10 @@ def test_tracer_headers_are_overwritten(self):
563582 kwargs = {'headers' : {'x-trace' : 'original-value' }}
564583
565584 with patch , patch_thread :
566- trace .wrap_session_request (wrapped , 'Session.request' ,
567- (request_method , url ), kwargs )
585+ trace .wrap_session_request (
586+ wrapped , 'Session.request' ,
587+ (request_method , url ), kwargs
588+ )
568589
569590 self .assertEqual (kwargs ['headers' ]['x-trace' ], 'some-value' )
570591
@@ -590,8 +611,11 @@ def test_wrap_session_request_timeout(self):
590611 kwargs = {}
591612
592613 with patch , patch_thread :
593- trace .wrap_session_request (wrapped , 'Session.request' ,
594- (request_method , url ), kwargs )
614+ with self .assertRaises (requests .Timeout ):
615+ trace .wrap_session_request (
616+ wrapped , 'Session.request' ,
617+ (request_method , url ), kwargs
618+ )
595619
596620 expected_attributes = {
597621 'http.host' : 'localhost:8080' ,
@@ -635,8 +659,11 @@ def test_wrap_session_request_invalid_url(self):
635659 kwargs = {}
636660
637661 with patch , patch_thread :
638- trace .wrap_session_request (wrapped , 'Session.request' ,
639- (request_method , url ), kwargs )
662+ with self .assertRaises (requests .URLRequired ):
663+ trace .wrap_session_request (
664+ wrapped , 'Session.request' ,
665+ (request_method , url ), kwargs
666+ )
640667
641668 expected_attributes = {
642669 'http.host' : 'localhost:8080' ,
@@ -680,8 +707,11 @@ def test_wrap_session_request_exception(self):
680707 kwargs = {}
681708
682709 with patch , patch_thread :
683- trace .wrap_session_request (wrapped , 'Session.request' ,
684- (request_method , url ), kwargs )
710+ with self .assertRaises (requests .TooManyRedirects ):
711+ trace .wrap_session_request (
712+ wrapped , 'Session.request' ,
713+ (request_method , url ), kwargs
714+ )
685715
686716 expected_attributes = {
687717 'http.host' : 'localhost:8080' ,
0 commit comments