Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

root/branches/cherrypy-2.x/cherrypy/test/test_combinedfilters.py

Revision 1017 (checked in by fumanchu, 3 years ago)

Initial fix for #498 (Test suite assumes same process for client and server). All test modules now wrap the server-side code in a "setup_server" function. New test\modpy module (with several tests failing).

  • Property svn:eol-style set to native
Line 
1 import test
2 test.prefer_parent_path()
3
4 import gzip, StringIO
5 import cherrypy
6
7 europoundUnicode = u'\x80\xa3'
8
9 def setup_server():
10     class Root:
11         def index(self):
12             yield u"Hello,"
13             yield u"world"
14             yield europoundUnicode
15         index.exposed = True
16
17     cherrypy.root = Root()
18     cherrypy.config.update({
19             'server.log_to_screen': False,
20             'server.environment': 'production',
21             'gzip_filter.on': True,
22             'encoding_filter.on': True,
23     })
24
25 import helper
26
27 class CombinedFiltersTest(helper.CPWebCase):
28    
29     def testCombinedFilters(self):
30         expectedResult = (u"Hello,world" + europoundUnicode).encode('utf-8')
31         zbuf = StringIO.StringIO()
32         zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=9)
33         zfile.write(expectedResult)
34         zfile.close()
35        
36         self.getPage("/", headers=[("Accept-Encoding", "gzip")])
37         self.assertInBody(zbuf.getvalue()[:3])
38
39
40 if __name__ == '__main__':
41     setup_server()
42     helper.testmain()
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets