44# license information.
55# --------------------------------------------------------------------------
66import logging
7- import six
87import os
98from typing import TYPE_CHECKING , Optional
109import urllib .parse as url_parse
@@ -87,8 +86,7 @@ def start_record_or_playback(test_id: str) -> "Tuple[str, Dict[str, str]]":
8786 body = encoded_payload ,
8887 )
8988 if result .status != 200 :
90- message = six .ensure_str (result .data )
91- raise HttpResponseError (message = message )
89+ raise HttpResponseError (message = result .data )
9290 recording_id = result .headers ["x-recording-id" ]
9391
9492 else :
@@ -98,21 +96,17 @@ def start_record_or_playback(test_id: str) -> "Tuple[str, Dict[str, str]]":
9896 body = encoded_payload ,
9997 )
10098 if result .status != 200 :
101- message = six .ensure_str (result .data )
102- raise HttpResponseError (message = message )
99+ raise HttpResponseError (message = result .data )
103100
104101 try :
105102 recording_id = result .headers ["x-recording-id" ]
106103 except KeyError as ex :
107- six . raise_from ( ValueError ("No recording file found for {}" . format ( test_id )), ex )
104+ raise ValueError (f "No recording file found for { test_id } " ) from ex
108105 if result .data :
109106 try :
110107 variables = json .loads (result .data .decode ("utf-8" ))
111- except ValueError as ex : # would be a JSONDecodeError on Python 3, which subclasses ValueError
112- six .raise_from (
113- ValueError ("The response body returned from starting playback did not contain valid JSON" ),
114- ex ,
115- )
108+ except ValueError as ex : # would be a JSONDecodeError, which subclasses ValueError
109+ raise ValueError ("The response body returned from starting playback did not contain valid JSON" ) from ex
116110
117111 # set recording ID in a module-level variable so that sanitizers can access it
118112 set_recording_id (test_id , recording_id )
@@ -245,7 +239,7 @@ def combined_call(*args, **kwargs):
245239 message = f"{ troubleshoot } Error details:\n { message } " ,
246240 response = error .response ,
247241 )
248- six . raise_from ( error_with_message , error )
242+ raise error_with_message from error
249243
250244 finally :
251245 RequestsTransport .send = original_transport_func
0 commit comments