/usr/share/pyshared/cherrypy/test/test_combinedfilters.py is in python-cherrypy 2.3.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import test
test.prefer_parent_path()
import gzip, StringIO
import cherrypy
europoundUnicode = u'\x80\xa3'
def setup_server():
class Root:
def index(self):
yield u"Hello,"
yield u"world"
yield europoundUnicode
index.exposed = True
cherrypy.root = Root()
cherrypy.config.update({
'server.log_to_screen': False,
'server.environment': 'production',
'gzip_filter.on': True,
'encoding_filter.on': True,
})
import helper
class CombinedFiltersTest(helper.CPWebCase):
def testCombinedFilters(self):
expectedResult = (u"Hello,world" + europoundUnicode).encode('utf-8')
zbuf = StringIO.StringIO()
zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=9)
zfile.write(expectedResult)
zfile.close()
self.getPage("/", headers=[("Accept-Encoding", "gzip")])
self.assertInBody(zbuf.getvalue()[:3])
if __name__ == '__main__':
setup_server()
helper.testmain()
|