source: web/old/sipbmp3web/tests/__init__.py @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 1.1 KB
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
13
14import pkg_resources
15import webtest
16import paste.script.appinstall
17from paste.deploy import loadapp
18from routes import url_for
19
20__all__ = ['url_for', 'TestController']
21
22here_dir = os.path.dirname(os.path.abspath(__file__))
23conf_dir = os.path.dirname(os.path.dirname(here_dir))
24
25sys.path.insert(0, conf_dir)
26pkg_resources.working_set.add_entry(conf_dir)
27pkg_resources.require('Paste')
28pkg_resources.require('PasteScript')
29
30test_file = os.path.join(conf_dir, 'test.ini')
31cmd = paste.script.appinstall.SetupCommand('setup-app')
32cmd.run([test_file])
33
34class TestController(object):
35
36    def __init__(self, *args, **kwargs):
37        wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
38        self.app = webtest.TestApp(wsgiapp)
Note: See TracBrowser for help on using the repository browser.