Flask unit tests with SQLAlchemy and PostgreSQL exhausts db connections
问题 I'm running a suite of fairly straightforward test cases using Flask, SQLAlchemy, and PostgreSQL. Using an application factory, I've defined a base unit test class like so: class BaseTestCase(unittest.TestCase): def setUp(self): self.app = create_app() self.app.config.from_object('app.config.test') self.api_base = '/api/v1' self.ctx = self.app.test_request_context() self.ctx.push() self.client = self.app.test_client() db.create_all() def tearDown(self): db.session.remove() db.drop_all(app