Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Pyramid has nothing to do with SQLAlchemy. There is nowhere in Pyramid's API where you would link any of your SQLAlchemy configuration in a way that Pyramid would actually care. Therefore, Pyramid's <code>testing.tearDown()</code> does not do anything with connections. How could it? It doesn't know they exist.</p> <p>You're using scoped sessions with a unit test, which really doesn't make a lot of sense because your unit tests are probably not threaded. So now you're creating threadlocal sessions and not cleaning them up. They aren't garbage collected because they're threadlocal. You also aren't manually closing those connections so the connection pool thinks they're still being used.</p> <p>Is there a reason you need the <code>ZopeTransactionExtension</code> in your tests? Are you using the <code>transaction</code> package in your tests, or <code>pyramid_tm</code>? In a test if you don't know what something does then it shouldn't be there. You're calling <code>create_all()</code> from your <code>setUp()</code> method? That's going to be slow as hell introspecting the database and creating tables on every request. Ouch.</p> <pre><code>class BaseTest(object): def setUp(self): self.request = testing.DummyRequest() self.config = testing.setUp(request=self.request) self.config.scan('../models') sqlalchemy_url = 'postgresql://&lt;user&gt;:&lt;pass&gt;@localhost:5432/&lt;db&gt;' self.engine = create_engine(sqlalchemy_url) Base.metadata.create_all(bind=self.engine) self.sessionmaker = sessionmaker(bind=self.engine) self.sessions = [] def makeSession(self, autoclose=True): session = self.sessionmaker() if autoclose: self.sessions.append(session) def tearDown(self): for session in self.sessions: session.close() self.engine.dispose() testing.teardown() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload