2 from cherrypy
.test
import helper
5 class WSGI_VirtualHost_Test(helper
.CPWebCase
):
9 class ClassOfRoot(object):
11 def __init__(self
, name
):
15 return "Welcome to the %s website!" % self
.name
19 default
= cherrypy
.Application(None)
22 for year
in range(1997, 2008):
23 app
= cherrypy
.Application(ClassOfRoot('Class of %s' % year
))
24 domains
['www.classof%s.example' % year
] = app
26 cherrypy
.tree
.graft(cherrypy
._cpwsgi
.VirtualHost(default
, domains
))
27 setup_server
= staticmethod(setup_server
)
29 def test_welcome(self
):
30 if not cherrypy
.server
.using_wsgi
:
31 return self
.skip("skipped (not using WSGI)... ")
33 for year
in range(1997, 2008):
34 self
.getPage("/", headers
=[('Host', 'www.classof%s.example' % year
)])
35 self
.assertBody("Welcome to the Class of %s website!" % year
)