Home | History | Annotate | Download | only in tests
      1 from paste.fixture import TestApp
      2 from paste.gzipper import middleware
      3 import gzip
      4 import six
      5 
      6 def simple_app(environ, start_response):
      7     start_response('200 OK', [('content-type', 'text/plain')])
      8     return [b'this is a test']
      9 
     10 wsgi_app = middleware(simple_app)
     11 app = TestApp(wsgi_app)
     12 
     13 def 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