File: test-wsgi.py

package info (click to toggle)
quixote 2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,036 kB
  • ctags: 1,131
  • sloc: python: 5,935; ansic: 1,436; makefile: 87; sh: 23
file content (26 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
import twill
import quixote
from qx_testserver import create_publisher

class TestWSGI:
    def setup(self):
        wsgi_app = None

        x = sys.stdout                      # Quixote mangles sys.stdout; save.
        try:
            publisher = create_publisher()
            wsgi_app = quixote.get_wsgi_app()
        finally:
            sys.stdout = x                      # restore.

        twill.add_wsgi_intercept('localhost', 80, lambda:wsgi_app, '/qx_test')

    def teardown(self):
        twill.remove_wsgi_intercept('localhost', 80)

        quixote.cleanup()

    def test(self):
        twill.commands.go('http://localhost:80/qx_test/')
        twill.commands.find('hello, world')