# HG changeset patch # User Marc Abramowitz # Date 1429293041 25200 # Node ID c2779dc2c1fbc45440a2cbecb59bb801885e22f6 # Parent ff4fc4b0e825de8a5a0d91a9619a80c0407a8ee4 tests: set app_globals and translater in conftest.py for py.test Copy over code from the pylons nose plugin for setting app_globals and for setting a translator object. This allows more of the functional tests to pass; particularly the ones related to i18n. diff -r ff4fc4b0e825 -r c2779dc2c1fb kallithea/tests/conftest.py --- a/kallithea/tests/conftest.py Wed Apr 08 10:48:07 2015 -0700 +++ b/kallithea/tests/conftest.py Fri Apr 17 10:50:41 2015 -0700 @@ -4,6 +4,7 @@ import pkg_resources from paste.deploy import loadapp import pylons.test +from pylons.i18n.translation import _get_translator def pytest_configure(): @@ -11,4 +12,18 @@ sys.path.insert(0, path) pkg_resources.working_set.add_entry(path) pylons.test.pylonsapp = loadapp('config:test.ini', relative_to=path) + + # Setup the config and app_globals, only works if we can get + # to the config object + conf = getattr(pylons.test.pylonsapp, 'config') + if conf: + pylons.config._push_object(conf) + + if 'pylons.app_globals' in conf: + pylons.app_globals._push_object(conf['pylons.app_globals']) + + # Initialize a translator for tests that utilize i18n + translator = _get_translator(pylons.config.get('lang')) + pylons.translator._push_object(translator) + return pylons.test.pylonsapp