def close(self): """Explicitly close the connection and remove it from the connection pool if pooling is enabled. :raises: AssertionError """ if not self._conn: raise AssertionError('Connection not open') if self._use_pool: pool.remove_connection(self.pid, self._conn) # Close the connection self._conn.close() self._conn, self._cursor = None, None
def test_invalid_pid_fails_silently(self): """Ensure passing an invalid pid doesnt not raise exception""" pool.remove_connection(self.connection, self)
def test_invalid_connection_fails_silently(self): """Ensure that passing an invalid pid doesnt raise an exception""" pool.remove_connection(self.pid, self)
def test_empty_pool_removed(self): """Ensure a removed connection is not in pool""" pool.remove_connection(self.pid, self.connection) pool.clean_pools() self.assertNotIn(self.pid, pool.Pools)
def test_remove_connection_removes_connection(self): """Ensure a removed connection is not in pool""" pool.remove_connection(self.pid, self.connection) self.assertNotIn(self.connection, pool.Pools[self.pid].connections)