mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Allow tests to be ignored if dynamic binding failed
This commit is contained in:
parent
5b4caadd23
commit
953bc66ca6
|
@ -350,14 +350,19 @@ class ConnectionTests(ConnectingTestCase):
|
|||
conn = self.connect()
|
||||
self.assert_(conn.pgconn_ptr is not None)
|
||||
|
||||
f = self.libpq.PQserverVersion
|
||||
f.argtypes = [ctypes.c_void_p]
|
||||
f.restype = ctypes.c_int
|
||||
ver = f(conn.pgconn_ptr)
|
||||
if ver == 0 and sys.platform == 'darwin':
|
||||
return self.skipTest("I don't know why this func returns 0 on OSX")
|
||||
try:
|
||||
f = self.libpq.PQserverVersion
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
f.argtypes = [ctypes.c_void_p]
|
||||
f.restype = ctypes.c_int
|
||||
ver = f(conn.pgconn_ptr)
|
||||
if ver == 0 and sys.platform == 'darwin':
|
||||
return self.skipTest(
|
||||
"I don't know why this func returns 0 on OSX")
|
||||
|
||||
self.assertEqual(ver, conn.server_version)
|
||||
self.assertEqual(ver, conn.server_version)
|
||||
|
||||
conn.close()
|
||||
self.assert_(conn.pgconn_ptr is None)
|
||||
|
|
|
@ -654,14 +654,18 @@ class CursorTests(ConnectingTestCase):
|
|||
curs = self.conn.cursor()
|
||||
self.assert_(curs.pgresult_ptr is None)
|
||||
|
||||
f = self.libpq.PQcmdStatus
|
||||
f.argtypes = [ctypes.c_void_p]
|
||||
f.restype = ctypes.c_char_p
|
||||
|
||||
curs.execute("select 'x'")
|
||||
self.assert_(curs.pgresult_ptr is not None)
|
||||
status = f(curs.pgresult_ptr)
|
||||
self.assertEqual(status, b'SELECT 1')
|
||||
|
||||
try:
|
||||
f = self.libpq.PQcmdStatus
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
f.argtypes = [ctypes.c_void_p]
|
||||
f.restype = ctypes.c_char_p
|
||||
status = f(curs.pgresult_ptr)
|
||||
self.assertEqual(status, b'SELECT 1')
|
||||
|
||||
curs.close()
|
||||
self.assert_(curs.pgresult_ptr is None)
|
||||
|
|
Loading…
Reference in New Issue
Block a user