PageRenderTime 132ms CodeModel.GetById 60ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/kai/tests/__init__.py

https://bitbucket.org/bbangert/kai/
Python | 34 lines | 17 code | 7 blank | 10 comment | 0 complexity | 5bcb98bc8c03582623167ab325e9f19b MD5 | raw file
 1"""Pylons application test package
 2
 3This package assumes the Pylons environment is already loaded, such as
 4when this script is imported from the `nosetests --with-pylons=test.ini`
 5command.
 6
 7This module initializes the application via ``websetup`` (`paster
 8setup-app`) and provides the base testing objects.
 9"""
10from unittest import TestCase
11
12from paste.deploy import loadapp
13from paste.script.appinstall import SetupCommand
14from pylons import url
15from routes.util import URLGenerator
16from webtest import TestApp
17
18import pylons.test
19
20__all__ = ['environ', 'url', 'TestController']
21
22# Invoke websetup with the current config file
23SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
24
25environ = {}
26
27class TestController(TestCase):
28
29    def __init__(self, *args, **kwargs):
30        wsgiapp = pylons.test.pylonsapp
31        config = wsgiapp.config
32        self.app = TestApp(wsgiapp)
33        url._push_object(URLGenerator(config['routes.map'], environ))
34        TestCase.__init__(self, *args, **kwargs)