From 98d6d96ee30bd54311f1644faf1b625602092606 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 23 Feb 2012 23:15:42 +0000 Subject: [PATCH] Fixed exception testing on Python 3 ...and so caught exceptions are local to the except suite in Py3. (Lo sapevate? Sapevatelo!) --- tests/test_module.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_module.py b/tests/test_module.py index 49889693..870dbbc2 100755 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -137,8 +137,10 @@ class ExceptionsTestCase(unittest.TestCase): def test_attributes(self): cur = self.conn.cursor() - try: cur.execute("select * from nonexist") - except psycopg2.Error, e: pass + try: + cur.execute("select * from nonexist") + except psycopg2.Error, exc: + e = exc self.assertEqual(e.pgcode, '42P01') self.assert_(e.pgerror) @@ -150,8 +152,8 @@ class ExceptionsTestCase(unittest.TestCase): cur = self.conn.cursor() try: cur.execute("select * from nonexist") - except psycopg2.Error, e: - pass + except psycopg2.Error, exc: + e = exc e1 = pickle.loads(pickle.dumps(e))