kennethreitz/django-postgrespool — pull request #5 by carljm (2012-11-16 00:33:24+00:00)
Title: Ensure test db conns are closed before dropping it.

In using django-postgrespool with pytest-django, the test db teardown errored out every time because the connection pool still held open a connection to the test database. This pull request fixes that.

(I haven't actually checked to see if this is a problem with the regular Django test runner as well as pytest-django; the fact that it hasn't been caught yet makes me think it isn't, though I can't immediately see why it wouldn't be. Maybe nobody else runs their tests using django-postgrespool, but I dislike introducing differences between test/dev and production if I can avoid it.)

The new ``DatabaseWrapper.dispose()`` method is more complex than it should need to be, due to what seems to be [a bug in SQLAlchemy's pool implementation](https://groups.google.com/d/msg/sqlalchemy/bw8tG7qdXfk/mnuaUjG6v1kJ). If that bug were fixed, the ``_dispose()`` method would just be a light wrapper around SQLAlchemy's ``_DBProxy.dispose``:

self.close()
db_pool.dispose(**self._get_conn_params())