mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Fixed exception handling in disconnection test
OperationalError is DatabaseError's subclass.
This commit is contained in:
parent
c5de7b5ac6
commit
af18c29f0b
|
@ -75,12 +75,14 @@ class ConnectionTests(unittest.TestCase):
|
|||
cur = conn.cursor()
|
||||
try:
|
||||
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:
|
||||
if e.pgcode != psycopg2.errorcodes.ADMIN_SHUTDOWN:
|
||||
raise
|
||||
except psycopg2.DatabaseError, e:
|
||||
# curiously when disconnected in green mode we get a DatabaseError
|
||||
# without pgcode.
|
||||
if e.pgcode is not None:
|
||||
raise
|
||||
|
||||
self.assertEqual(conn.closed, 2)
|
||||
conn.close()
|
||||
|
|
Loading…
Reference in New Issue
Block a user