comparison pylons_app/tests/__init__.py @ 459:7c978511c951

implemented basic (startup) nose test suite.
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 05 Sep 2010 16:20:29 +0200
parents 564e40829f80
children a03250279b15
comparison
equal deleted inserted replaced
458:00f883abdb0c 459:7c978511c951
12 from paste.deploy import loadapp 12 from paste.deploy import loadapp
13 from paste.script.appinstall import SetupCommand 13 from paste.script.appinstall import SetupCommand
14 from pylons import config, url 14 from pylons import config, url
15 from routes.util import URLGenerator 15 from routes.util import URLGenerator
16 from webtest import TestApp 16 from webtest import TestApp
17 import os
17 18
18 import pylons.test 19 import pylons.test
19 20
20 __all__ = ['environ', 'url', 'TestController'] 21 __all__ = ['environ', 'url', 'TestController']
21 22
22 # Invoke websetup with the current config file 23 # Invoke websetup with the current config file
23 SetupCommand('setup-app').run([config['__file__']]) 24 SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
24 25
25 environ = {} 26 environ = {}
26 27
27 class TestController(TestCase): 28 class TestController(TestCase):
28 29
29 def __init__(self, *args, **kwargs): 30 def __init__(self, *args, **kwargs):
30 if pylons.test.pylonsapp: 31 wsgiapp = pylons.test.pylonsapp
31 wsgiapp = pylons.test.pylonsapp 32 config = wsgiapp.config
32 else:
33 wsgiapp = loadapp('config:%s' % config['__file__'])
34 self.app = TestApp(wsgiapp) 33 self.app = TestApp(wsgiapp)
35 url._push_object(URLGenerator(config['routes.map'], environ)) 34 url._push_object(URLGenerator(config['routes.map'], environ))
36 TestCase.__init__(self, *args, **kwargs) 35 TestCase.__init__(self, *args, **kwargs)
36