Hi,

I have my webtest based testing set up like the following.

@pytest.fixture(scope="session")
def app():
    testing_config = {
        'sqlalchemy.url': 'postgresql+psycopg2://x@/x',
        'redis.sessions.secret': 'x',  # random string
        'redis.sessions.db': 1,
        'tm.annotate_user': 'no',
    }

    return main({"testing": True}, **testing_config)


@pytest.fixture
def testapp(app):
    return TestApp(app)

main() is a config.make_wsgi_app().

My questions is, how can I have direct database connection - normally a
request.dbsession in the app - in the testing fixtures? I'd like to run
some DB queries in the setup/teardown process.

I can access testapp.app or "app" from the fixtures, that works. What I
don't know is how can I get a request object from there.

In command line scripts I use

    request_dummy = Request.blank('/', base_url=base_url)
    env = bootstrap(config_uri, request=request_dummy)
    request = env['request']

Do I need to do something similar here?

Zsolt

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAKw-smAqGQjoX1h%2B_rWHjh6Pvi95Vb5RVQ5E%3Djf91B8AW6b1Yg%40mail.gmail.com.

Reply via email to