mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-05 00:15:46 +03:00
Keep into account psycopg build in lo64 tests
This commit is contained in:
parent
2f862972c9
commit
bc5e2aeead
|
@ -440,13 +440,23 @@ decorate_all_tests(LargeObjectTruncateTests,
|
|||
skip_if_no_lo, skip_lo_if_green, skip_if_no_truncate)
|
||||
|
||||
|
||||
def _has_lo64(conn):
|
||||
"""Return (bool, msg) about the lo64 support"""
|
||||
if conn.server_version < 90300:
|
||||
return (False, "server version %s doesn'ts support the lo64 API"
|
||||
% conn.server_version)
|
||||
|
||||
if 'lo64' not in psycopg2.__version__:
|
||||
return (False, "this psycopg build doesn't support the lo64 API")
|
||||
|
||||
return (True, "this server and build support the lo64 API")
|
||||
|
||||
def skip_if_no_lo64(f):
|
||||
@wraps(f)
|
||||
def skip_if_no_lo64_(self):
|
||||
if self.conn.server_version < 90300:
|
||||
return self.skipTest("large objects 64bit only supported from PG 9.3")
|
||||
else:
|
||||
return f(self)
|
||||
lo64, msg = _has_lo64(self.conn)
|
||||
if not lo64: return self.skipTest(msg)
|
||||
else: return f(self)
|
||||
|
||||
return skip_if_no_lo64_
|
||||
|
||||
|
@ -467,10 +477,9 @@ decorate_all_tests(LargeObject64Tests,
|
|||
def skip_if_lo64(f):
|
||||
@wraps(f)
|
||||
def skip_if_lo64_(self):
|
||||
if self.conn.server_version >= 90300:
|
||||
return self.skipTest("large objects 64bit only supported from PG 9.3")
|
||||
else:
|
||||
return f(self)
|
||||
lo64, msg = _has_lo64(self.conn)
|
||||
if lo64: return self.skipTest(msg)
|
||||
else: return f(self)
|
||||
|
||||
return skip_if_lo64_
|
||||
|
||||
|
@ -478,12 +487,16 @@ class LargeObjectNot64Tests(LargeObjectTestCase):
|
|||
def test_seek_larger_than_2gb(self):
|
||||
lo = self.conn.lobject()
|
||||
offset = 1 << 32 # 4gb
|
||||
self.assertRaises(psycopg2.InterfaceError, lo.seek, offset, 0)
|
||||
self.assertRaises(
|
||||
(psycopg2.InterfaceError, psycopg2.NotSupportedError),
|
||||
lo.seek, offset, 0)
|
||||
|
||||
def test_truncate_larger_than_2gb(self):
|
||||
lo = self.conn.lobject()
|
||||
length = 1 << 32 # 4gb
|
||||
self.assertRaises(psycopg2.InterfaceError, lo.truncate, length)
|
||||
self.assertRaises(
|
||||
(psycopg2.InterfaceError, psycopg2.NotSupportedError),
|
||||
lo.truncate, length)
|
||||
|
||||
decorate_all_tests(LargeObjectNot64Tests,
|
||||
skip_if_no_lo, skip_lo_if_green, skip_if_no_truncate, skip_if_lo64)
|
||||
|
|
Loading…
Reference in New Issue
Block a user