From e4424bdfdc20347c638d61f44cf6838aa75ce50a Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo <daniele.varrazzo@gmail.com> Date: Wed, 5 Oct 2011 00:12:35 +0100 Subject: [PATCH] Fixed tests to run with antebellum Postgres versions --- tests/test_cursor.py | 16 +++++++++------- tests/types_basic.py | 7 +++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 18278948..b71cf7d4 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -157,13 +157,16 @@ class CursorTests(unittest.TestCase): curs = self.conn.cursor(r'1-2-3 \ "test"') curs.execute("select data from invname order by data") self.assertEqual(curs.fetchall(), [(10,), (20,), (30,)]) - + def test_withhold(self): - self.assertRaises(psycopg2.ProgrammingError, self.conn.cursor, - withhold=True) - + self.assertRaises(psycopg2.ProgrammingError, self.conn.cursor, + withhold=True) + curs = self.conn.cursor() - curs.execute("drop table if exists withhold") + try: + curs.execute("drop table withhold") + except psycopg2.ProgrammingError: + self.conn.rollback() curs.execute("create table withhold (data int)") for i in (10, 20, 30): curs.execute("insert into withhold values (%s)", (i,)) @@ -183,11 +186,10 @@ class CursorTests(unittest.TestCase): curs.execute("select data from withhold order by data") self.conn.commit() self.assertEqual(curs.fetchall(), [(10,), (20,), (30,)]) - + curs = self.conn.cursor() curs.execute("drop table withhold") self.conn.commit() - @skip_before_postgres(8, 2) def test_iter_named_cursor_efficient(self): diff --git a/tests/types_basic.py b/tests/types_basic.py index 88c3844f..737b3770 100755 --- a/tests/types_basic.py +++ b/tests/types_basic.py @@ -297,6 +297,13 @@ class TypesBasicTests(unittest.TestCase): self.assertEqual(1, l1) def testGenericArray(self): + a = self.execute("select '{1,2,3}'::int4[]") + self.assertEqual(a, [1,2,3]) + a = self.execute("select array['a','b','''']::text[]") + self.assertEqual(a, ['a','b',"'"]) + + @testutils.skip_before_postgres(8, 2) + def testGenericArrayNull(self): def caster(s, cur): if s is None: return "nada" return int(s) * 2