1 from cherrypy.test import test
2 test.prefer_parent_path()
3
4 import os
5 localDir = os.path.join(os.getcwd(), os.path.dirname(__file__))
6 tidy_path = os.path.join(localDir, "tidy")
7
8 import cherrypy
9 from cherrypy import tools
10
11 doctype = ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '
12 '"http://www.w3.org/TR/xhtml1/DTD/strict.dtd">')
13
15 class Root:
16 _cp_config = {
17 'tools.tidy.on': True,
18 'tools.tidy.tidy_path': tidy_path,
19 'tools.tidy.temp_dir': localDir,
20 }
21
22 def plaintext(self):
23 yield "Hello, world"
24 plaintext.exposed = True
25 plaintext._cp_config = {'tools.tidy.warnings': False}
26
27 def validhtml(self):
28 return "<html><body><h1>This should be valid</h1></body></html>"
29 validhtml.exposed = True
30 validhtml._cp_config = {'tools.tidy.warnings': False}
31
32 def warning(self, skip_doctype=False):
33 if skip_doctype:
34
35 pass
36 else:
37 yield doctype
38
39 yield "<html><head><title>Meh</title></head>"
40 yield "<body>Normal body</body></html>"
41 warning.exposed = True
42
43 cherrypy.config.update({'environment': 'test_suite'})
44 cherrypy.tree.mount(Root())
45
46
47 from cherrypy.test import helper
48
72
73
74
75 if __name__ == "__main__":
76 setup_server()
77 helper.testmain()
78