If you have the app, the registry is attached as "app.registry" and you can use the underlying prepare() method with it, same as bootstrap does. See https://docs.pylonsproject.org/projects/pyramid/en/latest/api/scripting.html#pyramid.scripting.prepare <https://docs.pylonsproject.org/projects/pyramid/en/latest/api/scripting.html#pyramid.scripting.prepare>.
The rule of thumb is: if you have a registry, use prepare. If you have a config spec (ini file), use bootstrap. Prepare is way more lightweight because it reuses the configured registry whereas bootstrap creates an entirely new registry each time. - Michael > On Jun 24, 2021, at 12:33, Zsolt Ero <zsolt....@gmail.com> wrote: > > 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 pylons-discuss+unsubscr...@googlegroups.com > <mailto:pylons-discuss+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/CAKw-smAqGQjoX1h%2B_rWHjh6Pvi95Vb5RVQ5E%3Djf91B8AW6b1Yg%40mail.gmail.com > > <https://groups.google.com/d/msgid/pylons-discuss/CAKw-smAqGQjoX1h%2B_rWHjh6Pvi95Vb5RVQ5E%3Djf91B8AW6b1Yg%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- 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 pylons-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/93FFEDD1-B06D-4359-9D98-C270826ABE6C%40gmail.com.