diff options
Diffstat (limited to 'tests/test_lobject.py')
-rwxr-xr-x | tests/test_lobject.py | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/tests/test_lobject.py b/tests/test_lobject.py index e32673c..291a734 100755 --- a/tests/test_lobject.py +++ b/tests/test_lobject.py @@ -31,19 +31,11 @@ import psycopg2 import psycopg2.extensions import unittest from .testutils import (decorate_all_tests, skip_if_tpc_disabled, - ConnectingTestCase, skip_if_green, slow) + skip_before_postgres, ConnectingTestCase, skip_if_green, slow) -def skip_if_no_lo(f): - @wraps(f) - def skip_if_no_lo_(self): - if self.conn.info.server_version < 80100: - return self.skipTest("large objects only supported from PG 8.1") - else: - return f(self) - - return skip_if_no_lo_ - +skip_if_no_lo = skip_before_postgres(8, 1, + "large objects only supported from PG 8.1") skip_lo_if_green = skip_if_green("libpq doesn't support LO in async mode") @@ -73,6 +65,8 @@ class LargeObjectTestCase(ConnectingTestCase): ConnectingTestCase.tearDown(self) +@skip_if_no_lo +@skip_lo_if_green class LargeObjectTests(LargeObjectTestCase): def test_create(self): lo = self.conn.lobject() @@ -399,9 +393,7 @@ class LargeObjectTests(LargeObjectTestCase): self.assert_(isinstance(lo, lobject_subclass)) -decorate_all_tests(LargeObjectTests, skip_if_no_lo, skip_lo_if_green) - - +@decorate_all_tests def skip_if_no_truncate(f): @wraps(f) def skip_if_no_truncate_(self): @@ -419,6 +411,9 @@ def skip_if_no_truncate(f): return skip_if_no_truncate_ +@skip_if_no_lo +@skip_lo_if_green +@skip_if_no_truncate class LargeObjectTruncateTests(LargeObjectTestCase): def test_truncate(self): lo = self.conn.lobject() @@ -456,10 +451,6 @@ class LargeObjectTruncateTests(LargeObjectTestCase): self.assertRaises(psycopg2.ProgrammingError, lo.truncate) -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.info.server_version < 90300: @@ -472,6 +463,7 @@ def _has_lo64(conn): return True, "this server and build support the lo64 API" +@decorate_all_tests def skip_if_no_lo64(f): @wraps(f) def skip_if_no_lo64_(self): @@ -484,6 +476,10 @@ def skip_if_no_lo64(f): return skip_if_no_lo64_ +@skip_if_no_lo +@skip_lo_if_green +@skip_if_no_truncate +@skip_if_no_lo64 class LargeObject64Tests(LargeObjectTestCase): def test_seek_tell_truncate_greater_than_2gb(self): lo = self.conn.lobject() @@ -495,10 +491,7 @@ class LargeObject64Tests(LargeObjectTestCase): self.assertEqual(lo.tell(), length) -decorate_all_tests(LargeObject64Tests, - skip_if_no_lo, skip_lo_if_green, skip_if_no_truncate, skip_if_no_lo64) - - +@decorate_all_tests def skip_if_lo64(f): @wraps(f) def skip_if_lo64_(self): @@ -511,6 +504,10 @@ def skip_if_lo64(f): return skip_if_lo64_ +@skip_if_no_lo +@skip_lo_if_green +@skip_if_no_truncate +@skip_if_lo64 class LargeObjectNot64Tests(LargeObjectTestCase): def test_seek_larger_than_2gb(self): lo = self.conn.lobject() @@ -527,10 +524,6 @@ class LargeObjectNot64Tests(LargeObjectTestCase): lo.truncate, length) -decorate_all_tests(LargeObjectNot64Tests, - skip_if_no_lo, skip_lo_if_green, skip_if_no_truncate, skip_if_lo64) - - def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |