1from paste.fixture import TestApp 2from paste.gzipper import middleware 3import gzip 4import six 5 6def simple_app(environ, start_response): 7 start_response('200 OK', [('content-type', 'text/plain')]) 8 return [b'this is a test'] 9 10wsgi_app = middleware(simple_app) 11app = TestApp(wsgi_app) 12 13def test_gzip(): 14 res = app.get( 15 '/', extra_environ=dict(HTTP_ACCEPT_ENCODING='gzip')) 16 assert int(res.header('content-length')) == len(res.body) 17 assert res.body != b'this is a test' 18 actual = gzip.GzipFile(fileobj=six.BytesIO(res.body)).read() 19 assert actual == b'this is a test' 20