4
4
# license information.
5
5
# --------------------------------------------------------------------------
6
6
import logging
7
- import six
8
7
import os
9
8
from typing import TYPE_CHECKING , Optional
10
9
import urllib .parse as url_parse
@@ -87,8 +86,7 @@ def start_record_or_playback(test_id: str) -> "Tuple[str, Dict[str, str]]":
87
86
body = encoded_payload ,
88
87
)
89
88
if result .status != 200 :
90
- message = six .ensure_str (result .data )
91
- raise HttpResponseError (message = message )
89
+ raise HttpResponseError (message = result .data )
92
90
recording_id = result .headers ["x-recording-id" ]
93
91
94
92
else :
@@ -98,21 +96,17 @@ def start_record_or_playback(test_id: str) -> "Tuple[str, Dict[str, str]]":
98
96
body = encoded_payload ,
99
97
)
100
98
if result .status != 200 :
101
- message = six .ensure_str (result .data )
102
- raise HttpResponseError (message = message )
99
+ raise HttpResponseError (message = result .data )
103
100
104
101
try :
105
102
recording_id = result .headers ["x-recording-id" ]
106
103
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
108
105
if result .data :
109
106
try :
110
107
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
116
110
117
111
# set recording ID in a module-level variable so that sanitizers can access it
118
112
set_recording_id (test_id , recording_id )
@@ -245,7 +239,7 @@ def combined_call(*args, **kwargs):
245
239
message = f"{ troubleshoot } Error details:\n { message } " ,
246
240
response = error .response ,
247
241
)
248
- six . raise_from ( error_with_message , error )
242
+ raise error_with_message from error
249
243
250
244
finally :
251
245
RequestsTransport .send = original_transport_func
0 commit comments