Fixed handling of database disconnection in tests in green mode

This commit is contained in:
Daniele Varrazzo 2013-03-16 17:41:59 +00:00
parent e1ff432f4c
commit 594a4d79ec

View File

@ -75,6 +75,9 @@ class ConnectionTests(unittest.TestCase):
cur = conn.cursor() cur = conn.cursor()
try: try:
cur.execute("select pg_terminate_backend(pg_backend_pid())") cur.execute("select pg_terminate_backend(pg_backend_pid())")
except psycopg2.DatabaseError, e:
# curiously in green mode we get a DatabaseError without pgcode
pass
except psycopg2.OperationalError, e: except psycopg2.OperationalError, e:
if e.pgcode != psycopg2.errorcodes.ADMIN_SHUTDOWN: if e.pgcode != psycopg2.errorcodes.ADMIN_SHUTDOWN:
raise raise