Fixed tests to run with antebellum Postgres versions

This commit is contained in:
Daniele Varrazzo 2011-10-05 00:12:35 +01:00
parent 50b445fa12
commit e4424bdfdc
2 changed files with 16 additions and 7 deletions

View File

@ -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):

View File

@ -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