> On May 30, 5:06 am, Wyatt Baldwin <[email protected]> wrote:
>
> > On May 29, 5:57 pm, Evgeny <[email protected]> wrote:
>
> > > I'm switching from 0.9.7 to 1.0 and have a question. Changed my code
> > > as in upgrade manual.
>
> > > I'm using pylons.config in one of my functions in lib/helpers.py
> > > And testing it with nosetests.
>
> > > Just noticed that pylons.config is an empty structure during test.
>
> > > Is it a bug? Or any way to refer pylons config during tests?
>
> > Are you using Nose's --with-pylons option?
>
On May 29, 11:19 pm, Evgeny <[email protected]> wrote:
> All functional tests go well, so sure yes.
> and pylons.test.pylonsapp.config is available.
> But pylons.config is empty.

Without seeing your setup, it's hard to say what the problem is. Below
is how I'm doing things. It's a bit different from what's recommended
in the upgrade manual, but avoids certain issues I've had with the
"official" method.

# environment.py
from paste.deploy.converters import asbool
import pylons

def load_environment(global_conf, app_conf):
    # ...
    # I put the 'testing = true' in my test.ini
    config['testing'] = asbool(config.get('testing', 'false'))
    if config['testing']:
        test_environ = {
            # put stuff relevant to your test environ here, if you
need to
        }
        pylons.config._push_object(config)
        url._push_object(URLGenerator(config['routes.map'],
test_environ))
        config['test_environ'] = test_environ
    return config


# tests/__init__.py
from unittest import TestCase

from pylons import config
import pylons.test

from webtest import TestApp

class BaseTestController(TestCase):

    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        self.app = TestApp(wsgiapp,
extra_environ=config['test_environ'])
        TestCase.__init__(self, *args, **kwargs)


# middleware.py
def make_app(global_conf, full_stack=True, **app_conf):
    # ...
    # Do NOT add this line right before 'return app':
    app.config = config

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to