diff --git a/tests/test_connection.py b/tests/test_connection.py index 68de87ad..ca20868b 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -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()