PageRenderTime 114ms CodeModel.GetById 82ms RepoModel.GetById 10ms app.codeStats 0ms

/minger_plus/tests/__init__.py

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