Changeset - c2779dc2c1fb
[Not reviewed]
default
0 1 0
Marc Abramowitz - 11 years ago 2015-04-17 19:50:41
marc@marc-abramowitz.com
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.
1 file changed with 15 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/conftest.py
Show inline comments
 
import os
 
import sys
 

	
 
import pkg_resources
 
from paste.deploy import loadapp
 
import pylons.test
 
from pylons.i18n.translation import _get_translator
 

	
 

	
 
def pytest_configure():
 
    path = os.getcwd()
 
    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
0 comments (0 inline, 0 general)