blob: 4f929b019eb373ab9ea6533451a6da4625750e22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from paste.fixture import TestApp
from paste.gzipper import middleware
import gzip
from six.moves import cStringIO as StringIO
def simple_app(environ, start_response):
start_response('200 OK', [('content-type', 'text/plain')])
return 'this is a test'
wsgi_app = middleware(simple_app)
app = TestApp(wsgi_app)
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'
|