From 457e8e8b5ae0a4b6f5199a02fe435eaae0b4fcd8 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 13:07:54 -0500 Subject: [PATCH] TST: Don't depend on OperationalError for exceptions in connecting to test database --- tests/util.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/util.py b/tests/util.py index c7554d3..fba988b 100644 --- a/tests/util.py +++ b/tests/util.py @@ -24,13 +24,6 @@ if sys.version_info[:2] == (2, 6): else: import unittest -try: - import psycopg2 - from psycopg2 import OperationalError -except ImportError: - class OperationalError(Exception): - pass - def download_nybb(): """ Returns the path to the NYC boroughs file. Downloads if necessary. """ @@ -84,14 +77,17 @@ def create_db(df): # 'test_geopandas' and enable postgis in it: # > createdb test_geopandas # > psql -c "CREATE EXTENSION postgis" -d test_geopandas - con = connect('test_geopandas') + try: + con = connect('test_geopandas') + except: + return False if con is None: return False if PANDAS_NEW_SQL_API: try: con = con.connect() - except OperationalError: - return + except: + return False else: con = con.cursor()