Skip to content

Commit

Permalink
Refactor unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nateprewitt committed Jul 27, 2023
1 parent bd6249a commit f841379
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 203 deletions.
9 changes: 5 additions & 4 deletions botocore/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"""

import gzip
import io
import logging
from gzip import GzipFile
from gzip import compress as gzip_compress

from botocore.compat import urlencode
from botocore.utils import determine_content_length
Expand Down Expand Up @@ -88,9 +89,9 @@ def _get_body_size(body):

def _gzip_compress_body(body):
if isinstance(body, str):
return gzip.compress(body.encode('utf-8'))
return gzip_compress(body.encode('utf-8'))
elif isinstance(body, (bytes, bytearray)):
return gzip.compress(body)
return gzip_compress(body)
elif hasattr(body, 'read'):
if hasattr(body, 'seek') and hasattr(body, 'tell'):
current_position = body.tell()
Expand All @@ -102,7 +103,7 @@ def _gzip_compress_body(body):

def _gzip_compress_fileobj(body):
compressed_obj = io.BytesIO()
with gzip.GzipFile(fileobj=compressed_obj, mode='wb') as gz:
with GzipFile(fileobj=compressed_obj, mode='wb') as gz:
while True:
chunk = body.read(8192)
if not chunk:
Expand Down
Loading

0 comments on commit f841379

Please sign in to comment.