~noskcaj/ubuntu/vivid/webtest/merge2

« back to all changes in this revision

Viewing changes to docs/testapp_fixt.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Jakub Wilk, Piotr Ożarowski
  • Date: 2013-10-02 19:37:14 UTC
  • mfrom: (1.2.1) (14.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20131002193714-t0na13dhqrskvvff
Tags: 2.0.9-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Piotr Ożarowski ]
* New upstream release
  - bump minimum required Python version to 2.6
  - add python-six, python-waitress and python-bs4 to Depends
  - remove python-pastescript from Depends
  - remove python-simplejson and python-beautifulsoup from Recommends
  - add python-pyquery to Recommends
* Update debian/watch file to check for zip files
* Standards-Version bumped to 3.9.4 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
8
import json
 
9
import six
 
10
import sys
 
11
 
 
12
 
 
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)
 
29
 
 
30
 
 
31
def setup_test(test):
 
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
 
38
        else:
 
39
            example.options[ELLIPSIS] = 1
 
40
            example.options[NORMALIZE_WHITESPACE] = 1
 
41
 
 
42
setup_test.__test__ = False