Mercurial > kallithea
changeset 5022:c2779dc2c1fb
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.
author | Marc Abramowitz <marc@marc-abramowitz.com> |
---|---|
date | Fri, 17 Apr 2015 10:50:41 -0700 |
parents | ff4fc4b0e825 |
children | 45399ef99cdf |
files | kallithea/tests/conftest.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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