1
# -*- coding: utf-8 -*-
2
from doctest import NORMALIZE_WHITESPACE
3
from doctest import ELLIPSIS
4
from doctest import SKIP
5
from webtest import TestApp
6
from webob import Request
7
from webob import Response
13
def application(environ, start_response):
14
req = Request(environ)
15
if req.path_info.endswith('.html'):
16
content_type = 'text/html'
17
body = six.b('<html><body><div id="content">hey!</div></body>')
18
elif req.path_info.endswith('.xml'):
19
content_type = 'text/xml'
20
body = six.b('<xml><message>hey!</message></xml>')
21
elif req.path_info.endswith('.json'):
22
content_type = 'application/json'
23
body = json.dumps({"a": 1, "b": 2})
24
elif '/resource/' in req.path_info:
25
content_type = 'application/json'
26
body = json.dumps(dict(id=1, value='value'))
27
resp = Response(body, content_type=content_type)
28
return resp(environ, start_response)
32
ver = sys.version_info[:2]
33
test.globs.update(app=TestApp(application))
34
for example in test.examples:
35
if "'xml'" in example.want and ver == (2, 6):
36
# minidom node do not render the same in 2.6
37
example.options[SKIP] = 1
39
example.options[ELLIPSIS] = 1
40
example.options[NORMALIZE_WHITESPACE] = 1
42
setup_test.__test__ = False