summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-22 00:01:23 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-04-22 00:01:23 +0200
commit6b013060ce394c38a7f7a902d17c4c9a082a3df8 (patch)
treeb0138fe3094d857aac3d024e2d984288849759c7
parentceb5cfbb6b14dbab809decd1bbbbe8fc7411f437 (diff)
downloadpaste-git-6b013060ce394c38a7f7a902d17c4c9a082a3df8.tar.gz
Port gzipper to Python 3
-rw-r--r--paste/gzipper.py5
-rw-r--r--tests/test_gzipper.py10
2 files changed, 7 insertions, 8 deletions
diff --git a/paste/gzipper.py b/paste/gzipper.py
index 21b4164..eca8775 100644
--- a/paste/gzipper.py
+++ b/paste/gzipper.py
@@ -13,8 +13,7 @@ Gzip-encodes the response.
import gzip
from paste.response import header_value, remove_header
from paste.httpheaders import CONTENT_LENGTH
-
-from six.moves import cStringIO as StringIO
+import six
class GzipOutput(object):
pass
@@ -43,7 +42,7 @@ class GzipResponse(object):
def __init__(self, start_response, compress_level):
self.start_response = start_response
self.compress_level = compress_level
- self.buffer = StringIO()
+ self.buffer = six.BytesIO()
self.compressible = False
self.content_length = None
diff --git a/tests/test_gzipper.py b/tests/test_gzipper.py
index 4f929b0..54b7901 100644
--- a/tests/test_gzipper.py
+++ b/tests/test_gzipper.py
@@ -1,11 +1,11 @@
from paste.fixture import TestApp
from paste.gzipper import middleware
import gzip
-from six.moves import cStringIO as StringIO
+import six
def simple_app(environ, start_response):
start_response('200 OK', [('content-type', 'text/plain')])
- return 'this is a test'
+ return [b'this is a test']
wsgi_app = middleware(simple_app)
app = TestApp(wsgi_app)
@@ -14,6 +14,6 @@ def test_gzip():
res = app.get(
'/', extra_environ=dict(HTTP_ACCEPT_ENCODING='gzip'))
assert int(res.header('content-length')) == len(res.body)
- assert res.body != 'this is a test'
- actual = gzip.GzipFile(fileobj=StringIO(res.body)).read()
- assert actual == 'this is a test'
+ assert res.body != b'this is a test'
+ actual = gzip.GzipFile(fileobj=six.BytesIO(res.body)).read()
+ assert actual == b'this is a test'