Skip to content

Commit 4df650d

Browse files
authored
Remove six use in azure-sdk-tools (Azure#42665)
1 parent 0066659 commit 4df650d

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

eng/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
import functools
77
import logging
88
import os
9-
import os.path
10-
import re
11-
import six
129
import sys
1310
import time
14-
from typing import Dict
1511

1612
from dotenv import load_dotenv, find_dotenv
1713

@@ -24,7 +20,6 @@
2420
from .fake_credentials import SANITIZED
2521
from .fake_credentials_async import AsyncFakeCredential
2622
from .helpers import is_live, trim_kwargs_from_test_function
27-
from .sanitizers import add_general_string_sanitizer
2823

2924

3025
_LOGGER = logging.getLogger()
@@ -77,7 +72,7 @@ def get_settings_value(self, key):
7772
try:
7873
key_value = getattr(self.settings, key)
7974
except Exception as ex:
80-
six.raise_from(ValueError("Could not get {}".format(key)), ex)
75+
raise ValueError(f"Could not get {key}") from ex
8176
return key_value
8277

8378
def get_credential(self, client_class, **kwargs):

eng/tools/azure-sdk-tools/devtools_testutils/proxy_testcase.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# license information.
55
# --------------------------------------------------------------------------
66
import logging
7-
import six
87
import os
98
from typing import TYPE_CHECKING, Optional
109
import 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

Comments
 (0)