Clean up some warnings

Change-Id: Iae149533d04c7b173c4ef88fb775f5fe13c16466
This commit is contained in:
Tim Burke 2020-06-17 21:05:03 -07:00
parent b63d9a3e96
commit 22d1f3a39a
2 changed files with 29 additions and 26 deletions
swiftclient
test/unit

@ -14,7 +14,10 @@
# limitations under the License.
"""Miscellaneous utility functions for use with Swift."""
from calendar import timegm
import collections
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
import gzip
import hashlib
import hmac
@ -218,7 +221,7 @@ def parse_api_response(headers, body):
def split_request_headers(options, prefix=''):
headers = {}
if isinstance(options, collections.Mapping):
if isinstance(options, Mapping):
options = options.items()
for item in options:
if isinstance(item, six.string_types):

@ -521,7 +521,7 @@ class TestLengthWrapper(unittest.TestCase):
with tempfile.NamedTemporaryFile(mode='wb') as f:
f.write(b'a' * 100)
f.flush()
contents = open(f.name, 'rb')
with open(f.name, 'rb') as contents:
data = u.LengthWrapper(contents, 42, True)
s = b'a' * 42
read_data = b''.join(iter(data.read, ''))
@ -539,7 +539,7 @@ class TestLengthWrapper(unittest.TestCase):
f.write((c * segment_length).encode())
f.flush()
for i, c in enumerate(segments):
contents = open(f.name, 'rb')
with open(f.name, 'rb') as contents:
contents.seek(i * segment_length)
data = u.LengthWrapper(contents, segment_length, True)
read_data = b''.join(iter(data.read, ''))