Skip to content

Commit 8714c03

Browse files
tox fixes
1 parent 998572c commit 8714c03

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

SoftLayer/transports.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,16 @@ def _format_object_mask(objectmask):
568568
objectmask = "mask[%s]" % objectmask
569569
return objectmask
570570

571+
571572
class ComplexEncoder(json.JSONEncoder):
572-
def default(self, obj):
573+
"""ComplexEncoder helps jsonencoder deal with byte strings"""
574+
575+
def default(self, o):
576+
"""Encodes o as JSON"""
577+
573578
# Base64 encode bytes type objects.
574-
if isinstance(obj, bytes):
575-
base64_bytes = base64.b64encode(obj)
579+
if isinstance(o, bytes):
580+
base64_bytes = base64.b64encode(o)
576581
return base64_bytes.decode("utf-8")
577582
# Let the base class default method raise the TypeError
578-
return json.JSONEncoder.default(self, obj)
583+
return json.JSONEncoder.default(self, o)

tests/transport_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ def test_with_args(self, request):
528528
proxies=None,
529529
timeout=None)
530530

531-
532531
@mock.patch('SoftLayer.transports.requests.Session.request')
533532
def test_with_args_bytes(self, request):
534533
request().text = '{}'
@@ -702,7 +701,7 @@ def test_print_reproduceable(self):
702701

703702
def test_complex_encoder_bytes(self):
704703
to_encode = {
705-
'test' : ['array', 0, 1, False],
704+
'test': ['array', 0, 1, False],
706705
'bytes': b'ASDASDASD'
707706
}
708707
result = json.dumps(to_encode, cls=transports.ComplexEncoder)

0 commit comments

Comments
 (0)