diff options
author | matt <matt@xcolour.net> | 2013-01-28 11:32:18 -0500 |
---|---|---|
committer | matt <matt@xcolour.net> | 2013-01-28 11:32:18 -0500 |
commit | 1afcb52d73271bbbd78f885451aa1b0e78c09871 (patch) | |
tree | 9145840d6036fcbc0b6647c88f679a567fa8c54d /tests/test_gzipper.py | |
download | paste-git-stringio.tar.gz |
Import StringIO so it can be used.stringio
Diffstat (limited to 'tests/test_gzipper.py')
-rw-r--r-- | tests/test_gzipper.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_gzipper.py b/tests/test_gzipper.py new file mode 100644 index 0000000..0832700 --- /dev/null +++ b/tests/test_gzipper.py @@ -0,0 +1,18 @@ +from paste.fixture import TestApp +from paste.gzipper import middleware +import gzip, cStringIO + +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=cStringIO.StringIO(res.body)).read() + assert actual == 'this is a test' |