source: TI12-security/trunk/NDGSecurity/python/Tests/openid-provider/op/op/tests/__init__.py @ 7080

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDGSecurity/python/Tests/openid-provider/op/op/tests/__init__.py@7080
Revision 7080, 1.2 KB checked in by pjkersha, 9 years ago (diff)
  • Property svn:keywords set to Id
Line 
1"""Pylons application test package
2
3When the test runner finds and executes tests within this directory,
4this file will be loaded to setup the test environment.
5
6It registers the root directory of the project in sys.path and
7pkg_resources, in case the project hasn't been installed with
8setuptools. It also initializes the application via websetup (paster
9setup-app) with the project's test.ini configuration file.
10"""
11import os
12import sys
13from unittest import TestCase
14
15import pkg_resources
16import paste.fixture
17import paste.script.appinstall
18from paste.deploy import loadapp
19from routes import url_for
20
21__all__ = ['url_for', 'TestController']
22
23here_dir = os.path.dirname(os.path.abspath(__file__))
24conf_dir = os.path.dirname(os.path.dirname(here_dir))
25
26sys.path.insert(0, conf_dir)
27pkg_resources.working_set.add_entry(conf_dir)
28pkg_resources.require('Paste')
29pkg_resources.require('PasteScript')
30
31test_file = os.path.join(conf_dir, 'test.ini')
32cmd = paste.script.appinstall.SetupCommand('setup-app')
33cmd.run([test_file])
34
35class TestController(TestCase):
36
37    def __init__(self, *args, **kwargs):
38        wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
39        self.app = paste.fixture.TestApp(wsgiapp)
40        TestCase.__init__(self, *args, **kwargs)
Note: See TracBrowser for help on using the repository browser.