Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional test warning when app uses SQLAlchemy and binds engine #5

Closed
domenkozar opened this issue Nov 13, 2012 · 5 comments
Closed

Comments

@domenkozar
Copy link
Member

Anonymous:

I'm getting the following warning:
SAWarning: At least one scoped session is already present.
configure() can not affect sessions that have already been created.

The Warning is raised when TestApp.post() or .get() is called
for the SECOND time in the life of entire test, but only once. The
warning is raised at the second of these two lines of code:

DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) DBSession.configure(bind=engine)

This code is called ONCE per application startup (per default
Pyramid pyramid_routesalchemy template setup).

URL: https://bitbucket.org/ianb/webtest/issue/27/functional-test-warning-when-app-uses

@domenkozar
Copy link
Member Author

This is something a user should handle, nothing in the scope of WebTest. Indeed, SQLAlchemy raises a warning when you try to configure an engine for the second time.

@fweep
Copy link

fweep commented Aug 1, 2013

I'm having the same problem with my WebTest tests. Stumbled on this while Googling, and still haven't found a solution. If anyone stops by here and knows how to resolve this, please comment.

@domenkozar
Copy link
Member Author

put a pdb when you assemble the session, run the tests and you'll see when it's called for the second time

@dobesv
Copy link

dobesv commented Jun 3, 2014

You can call DBSession.remove() prior to calling DBSession.configure() in your test set up code.

@crooksey
Copy link

@dobesv Thanks, that's awesome, anyone +1 to put this in the webtest docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants