From 0654cf5a8ea1d705c5e8dd2441a7318ed43556c0 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 9 Feb 2020 07:15:56 -0800 Subject: [PATCH] Remove support for PostgrSQL server < 8.2 --- NEWS | 5 ++ doc/src/install.rst | 2 +- psycopg/connection.h | 9 ---- psycopg/connection_int.c | 10 ---- psycopg/connection_type.c | 5 -- psycopg/cursor_type.c | 4 +- psycopg/pqpath.c | 3 +- scripts/travis_prepare.sh | 3 -- scripts/travis_test.sh | 3 -- tests/test_async.py | 2 - tests/test_async_keyword.py | 1 - tests/test_cancel.py | 4 +- tests/test_connection.py | 81 +++++++-------------------------- tests/test_copy.py | 3 +- tests/test_cursor.py | 10 ---- tests/test_dates.py | 2 - tests/test_extras_dictcursor.py | 13 +----- tests/test_fast_executemany.py | 2 - tests/test_green.py | 1 - tests/test_ipaddress.py | 2 - tests/test_lobject.py | 9 +--- tests/test_quote.py | 8 ++-- tests/test_sql.py | 4 +- tests/test_transaction.py | 3 +- tests/test_types_basic.py | 4 -- tests/test_types_extras.py | 27 ----------- tests/test_with.py | 3 +- 27 files changed, 35 insertions(+), 188 deletions(-) diff --git a/NEWS b/NEWS index 0968b1f2..c3438513 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ Current release --------------- +UNRELEASED +^^^^^^^^^^ + +- Removed support for PostgreSQL server < 8.2. + What's new in psycopg 2.8.5 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/src/install.rst b/doc/src/install.rst index 017d090a..b1d99a29 100644 --- a/doc/src/install.rst +++ b/doc/src/install.rst @@ -36,7 +36,7 @@ The current `!psycopg2` implementation supports: - Python version 2.7 - Python 3 versions from 3.4 to 3.8 -- PostgreSQL server versions from 7.4 to 12 +- PostgreSQL server versions from 8.2 to 12 - PostgreSQL client library version from 9.1 diff --git a/psycopg/connection.h b/psycopg/connection.h index a78cdcec..4b31dcb0 100644 --- a/psycopg/connection.h +++ b/psycopg/connection.h @@ -199,15 +199,6 @@ HIDDEN void conn_set_error(connectionObject *self, const char *msg); return NULL; \ } -#define EXC_IF_TPC_NOT_SUPPORTED(self) \ - if ((self)->server_version < 80100) { \ - PyErr_Format(NotSupportedError, \ - "server version %d: " \ - "two-phase transactions not supported", \ - (self)->server_version); \ - return NULL; \ - } - #define EXC_IF_TPC_BEGIN(self, cmd) if ((self)->tpc_xid) { \ PyErr_Format(ProgrammingError, "%s cannot be used " \ "during a two-phase transaction", #cmd); \ diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 78dbd469..cfc10ac7 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -1279,16 +1279,6 @@ conn_set_session(connectionObject *self, int autocommit, goto exit; } - /* Promote an isolation level to one of the levels supported by the server */ - if (self->server_version < 80000) { - if (isolevel == ISOLATION_LEVEL_READ_UNCOMMITTED) { - isolevel = ISOLATION_LEVEL_READ_COMMITTED; - } - else if (isolevel == ISOLATION_LEVEL_REPEATABLE_READ) { - isolevel = ISOLATION_LEVEL_SERIALIZABLE; - } - } - Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&self->lock); diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 25299fab..fcd067b3 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -193,7 +193,6 @@ static PyObject * psyco_conn_xid(connectionObject *self, PyObject *args, PyObject *kwargs) { EXC_IF_CONN_CLOSED(self); - EXC_IF_TPC_NOT_SUPPORTED(self); return PyObject_Call((PyObject *)&xidType, args, kwargs); } @@ -211,7 +210,6 @@ psyco_conn_tpc_begin(connectionObject *self, PyObject *args) EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, tpc_begin); - EXC_IF_TPC_NOT_SUPPORTED(self); EXC_IF_IN_TRANSACTION(self, tpc_begin); if (!PyArg_ParseTuple(args, "O", &oxid)) { @@ -365,7 +363,6 @@ psyco_conn_tpc_commit(connectionObject *self, PyObject *args) { EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, tpc_commit); - EXC_IF_TPC_NOT_SUPPORTED(self); return _psyco_conn_tpc_finish(self, args, conn_commit, "COMMIT PREPARED"); @@ -379,7 +376,6 @@ psyco_conn_tpc_rollback(connectionObject *self, PyObject *args) { EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, tpc_rollback); - EXC_IF_TPC_NOT_SUPPORTED(self); return _psyco_conn_tpc_finish(self, args, conn_rollback, "ROLLBACK PREPARED"); @@ -394,7 +390,6 @@ psyco_conn_tpc_recover(connectionObject *self, PyObject *dummy) EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, tpc_recover); EXC_IF_TPC_PREPARED(self, tpc_recover); - EXC_IF_TPC_NOT_SUPPORTED(self); return conn_tpc_recover(self); } diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index a7bd11b4..a733641d 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -84,9 +84,9 @@ curs_close(cursorObject *self, PyObject *dummy) * closed (#746). * * So if we didn't execute() check for the cursor existence before - * closing it (the view exists since PG 8.2 according to docs). + * closing it. */ - if (!self->query && self->conn->server_version >= 80200) { + if (!self->query) { if (!(lname = psyco_escape_string( self->conn, self->name, -1, NULL, NULL))) { goto exit; diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index e52ba187..30e97aa7 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -360,8 +360,7 @@ pq_begin_locked(connectionObject *conn, PyThreadState **tstate) } else { snprintf(buf, bufsize, - conn->server_version >= 80000 ? - "BEGIN%s%s%s%s" : "BEGIN;SET TRANSACTION%s%s%s%s", + "BEGIN%s%s%s%s", (conn->isolevel >= 1 && conn->isolevel <= 4) ? " ISOLATION LEVEL " : "", (conn->isolevel >= 1 && conn->isolevel <= 4) diff --git a/scripts/travis_prepare.sh b/scripts/travis_prepare.sh index 1e18593b..d84a4427 100755 --- a/scripts/travis_prepare.sh +++ b/scripts/travis_prepare.sh @@ -128,9 +128,6 @@ fi # Unsupported postgres versions that we still support # Images built by https://github.com/psycopg/psycopg2-wheels/tree/build-dinosaurs if (( "$TEST_PAST" )); then - create 7.4 - create 8.0 - create 8.1 create 8.2 create 8.3 create 8.4 diff --git a/scripts/travis_test.sh b/scripts/travis_test.sh index a3de9ecc..db8b120d 100755 --- a/scripts/travis_test.sh +++ b/scripts/travis_test.sh @@ -64,9 +64,6 @@ if (( "$TEST_PAST" )); then run_test 8.4 run_test 8.3 run_test 8.2 - run_test 8.1 - run_test 8.0 - run_test 7.4 fi # Postgres built from master diff --git a/tests/test_async.py b/tests/test_async.py index d62eb3b0..3d12fa4f 100755 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -101,7 +101,6 @@ class AsyncTests(ConnectingTestCase): self.assertEquals(cur.fetchone()[0], "a") @slow - @skip_before_postgres(8, 2) def test_async_callproc(self): cur = self.conn.cursor() cur.callproc("pg_sleep", (0.1, )) @@ -460,7 +459,6 @@ class AsyncTests(ConnectingTestCase): else: self.fail("no exception raised") - @skip_before_postgres(8, 2) def test_copy_no_hang(self): cur = self.conn.cursor() cur.execute("copy (select 1) to stdout") diff --git a/tests/test_async_keyword.py b/tests/test_async_keyword.py index e1126928..62fb4315 100755 --- a/tests/test_async_keyword.py +++ b/tests/test_async_keyword.py @@ -103,7 +103,6 @@ class CancelTests(ConnectingTestCase): self.conn.commit() @slow - @skip_before_postgres(8, 2) def test_async_cancel(self): async_conn = psycopg2.connect(dsn, async=True) self.assertRaises(psycopg2.OperationalError, async_conn.cancel) diff --git a/tests/test_cancel.py b/tests/test_cancel.py index 4c60c0b7..988041cc 100755 --- a/tests/test_cancel.py +++ b/tests/test_cancel.py @@ -33,7 +33,7 @@ from psycopg2 import extras from .testconfig import dsn import unittest -from .testutils import ConnectingTestCase, skip_before_postgres, slow +from .testutils import ConnectingTestCase, slow class CancelTests(ConnectingTestCase): @@ -52,7 +52,6 @@ class CancelTests(ConnectingTestCase): self.conn.cancel() @slow - @skip_before_postgres(8, 2) def test_cancel(self): errors = [] @@ -90,7 +89,6 @@ class CancelTests(ConnectingTestCase): self.assertEqual(errors, []) @slow - @skip_before_postgres(8, 2) def test_async_cancel(self): async_conn = psycopg2.connect(dsn, async_=True) self.assertRaises(psycopg2.OperationalError, async_conn.cancel) diff --git a/tests/test_connection.py b/tests/test_connection.py index f1668d55..85acbbfe 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -202,16 +202,7 @@ class ConnectionTests(ConnectingTestCase): self.assert_(self.conn.protocol_version in (2, 3), self.conn.protocol_version) - def test_tpc_unsupported(self): - cnn = self.conn - if cnn.info.server_version >= 80100: - return self.skipTest("tpc is supported") - - self.assertRaises(psycopg2.NotSupportedError, - cnn.xid, 42, "foo", "bar") - @slow - @skip_before_postgres(8, 2) def test_concurrent_execution(self): def slave(): cnn = self.connect() @@ -595,13 +586,6 @@ class IsolationLevelsTestCase(ConnectingTestCase): for name, level in levels: conn.set_isolation_level(level) - # the only values available on prehistoric PG versions - if conn.info.server_version < 80000: - if level in ( - ext.ISOLATION_LEVEL_READ_UNCOMMITTED, - ext.ISOLATION_LEVEL_REPEATABLE_READ): - name, level = levels[levels.index((name, level)) + 1] - self.assertEqual(conn.isolation_level, level) curs.execute('show transaction_isolation;') @@ -776,14 +760,9 @@ class IsolationLevelsTestCase(ConnectingTestCase): self.conn.isolation_level = ext.ISOLATION_LEVEL_REPEATABLE_READ cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_REPEATABLE_READ) - self.assertEqual(cur.fetchone()[0], 'repeatable read') - else: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_SERIALIZABLE) - self.assertEqual(cur.fetchone()[0], 'serializable') + self.assertEqual(self.conn.isolation_level, + ext.ISOLATION_LEVEL_REPEATABLE_READ) + self.assertEqual(cur.fetchone()[0], 'repeatable read') self.conn.rollback() self.conn.isolation_level = ext.ISOLATION_LEVEL_READ_COMMITTED @@ -795,14 +774,9 @@ class IsolationLevelsTestCase(ConnectingTestCase): self.conn.isolation_level = ext.ISOLATION_LEVEL_READ_UNCOMMITTED cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_READ_UNCOMMITTED) - self.assertEqual(cur.fetchone()[0], 'read uncommitted') - else: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_READ_COMMITTED) - self.assertEqual(cur.fetchone()[0], 'read committed') + self.assertEqual(self.conn.isolation_level, + ext.ISOLATION_LEVEL_READ_UNCOMMITTED) + self.assertEqual(cur.fetchone()[0], 'read uncommitted') self.conn.rollback() self.assertEqual(ext.ISOLATION_LEVEL_DEFAULT, None) @@ -824,14 +798,9 @@ class IsolationLevelsTestCase(ConnectingTestCase): self.conn.isolation_level = "repeatable read" cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_REPEATABLE_READ) - self.assertEqual(cur.fetchone()[0], 'repeatable read') - else: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_SERIALIZABLE) - self.assertEqual(cur.fetchone()[0], 'serializable') + self.assertEqual(self.conn.isolation_level, + ext.ISOLATION_LEVEL_REPEATABLE_READ) + self.assertEqual(cur.fetchone()[0], 'repeatable read') self.conn.rollback() self.conn.isolation_level = "read committed" @@ -843,14 +812,9 @@ class IsolationLevelsTestCase(ConnectingTestCase): self.conn.isolation_level = "read uncommitted" cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_READ_UNCOMMITTED) - self.assertEqual(cur.fetchone()[0], 'read uncommitted') - else: - self.assertEqual(self.conn.isolation_level, - ext.ISOLATION_LEVEL_READ_COMMITTED) - self.assertEqual(cur.fetchone()[0], 'read committed') + self.assertEqual(self.conn.isolation_level, + ext.ISOLATION_LEVEL_READ_UNCOMMITTED) + self.assertEqual(cur.fetchone()[0], 'read uncommitted') self.conn.rollback() self.conn.isolation_level = "default" @@ -1265,10 +1229,7 @@ class TransactionControlTests(ConnectingTestCase): self.conn.set_session( ext.ISOLATION_LEVEL_REPEATABLE_READ) cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(cur.fetchone()[0], 'repeatable read') - else: - self.assertEqual(cur.fetchone()[0], 'serializable') + self.assertEqual(cur.fetchone()[0], 'repeatable read') self.conn.rollback() self.conn.set_session( @@ -1280,10 +1241,7 @@ class TransactionControlTests(ConnectingTestCase): self.conn.set_session( isolation_level=ext.ISOLATION_LEVEL_READ_UNCOMMITTED) cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(cur.fetchone()[0], 'read uncommitted') - else: - self.assertEqual(cur.fetchone()[0], 'read committed') + self.assertEqual(cur.fetchone()[0], 'read uncommitted') self.conn.rollback() def test_set_isolation_level_str(self): @@ -1295,10 +1253,7 @@ class TransactionControlTests(ConnectingTestCase): self.conn.set_session("repeatable read") cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(cur.fetchone()[0], 'repeatable read') - else: - self.assertEqual(cur.fetchone()[0], 'serializable') + self.assertEqual(cur.fetchone()[0], 'repeatable read') self.conn.rollback() self.conn.set_session("read committed") @@ -1308,10 +1263,7 @@ class TransactionControlTests(ConnectingTestCase): self.conn.set_session("read uncommitted") cur.execute("SHOW transaction_isolation;") - if self.conn.info.server_version > 80000: - self.assertEqual(cur.fetchone()[0], 'read uncommitted') - else: - self.assertEqual(cur.fetchone()[0], 'read committed') + self.assertEqual(cur.fetchone()[0], 'read uncommitted') self.conn.rollback() def test_bad_isolation_level(self): @@ -1685,7 +1637,6 @@ class PasswordLeakTestCase(ConnectingTestCase): class SignalTestCase(ConnectingTestCase): @slow - @skip_before_postgres(8, 2) def test_bug_551_returning(self): # Raise an exception trying to decode 'id' self._test_bug_551(query=""" diff --git a/tests/test_copy.py b/tests/test_copy.py index 4fdf1641..525ada0e 100755 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -27,7 +27,7 @@ import io import sys import string import unittest -from .testutils import (ConnectingTestCase, skip_before_postgres, slow, StringIO) +from .testutils import ConnectingTestCase, slow, StringIO from itertools import cycle from subprocess import Popen, PIPE @@ -276,7 +276,6 @@ class CopyTests(ConnectingTestCase): curs.execute("select count(*) from manycols;") self.assertEqual(curs.fetchone()[0], 2) - @skip_before_postgres(8, 2) # they don't send the count def test_copy_rowcount(self): curs = self.conn.cursor() diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 4d180962..ea21bbb2 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -335,7 +335,6 @@ class CursorTests(ConnectingTestCase): self.assertRaises(psycopg2.OperationalError, curs.scroll, -1) @slow - @skip_before_postgres(8, 2) def test_iter_named_cursor_efficient(self): curs = self.conn.cursor('tmp') # if these records are fetched in the same roundtrip their @@ -349,7 +348,6 @@ class CursorTests(ConnectingTestCase): "named cursor records fetched in 2 roundtrips (delta: %s)" % (t2 - t1)) - @skip_before_postgres(8, 0) def test_iter_named_cursor_default_itersize(self): curs = self.conn.cursor('tmp') curs.execute('select generate_series(1,50)') @@ -357,7 +355,6 @@ class CursorTests(ConnectingTestCase): # everything swallowed in one gulp self.assertEqual(rv, [(i, i) for i in range(1, 51)]) - @skip_before_postgres(8, 0) def test_iter_named_cursor_itersize(self): curs = self.conn.cursor('tmp') curs.itersize = 30 @@ -366,7 +363,6 @@ class CursorTests(ConnectingTestCase): # everything swallowed in two gulps self.assertEqual(rv, [(i, ((i - 1) % 30) + 1) for i in range(1, 51)]) - @skip_before_postgres(8, 0) def test_iter_named_cursor_rownumber(self): curs = self.conn.cursor('tmp') # note: this fails if itersize < dataset: internally we check @@ -443,7 +439,6 @@ class CursorTests(ConnectingTestCase): self.assertEqual(description, unpickled) - @skip_before_postgres(8, 0) def test_named_cursor_stealing(self): # you can use a named cursor to iterate on a refcursor created # somewhere else @@ -457,12 +452,10 @@ class CursorTests(ConnectingTestCase): self.assertEqual([(2,), (3,), (4,)], cur2.fetchmany(3)) self.assertEqual([(5,), (6,), (7,)], cur2.fetchall()) - @skip_before_postgres(8, 2) def test_named_noop_close(self): cur = self.conn.cursor('test') cur.close() - @skip_before_postgres(8, 2) def test_stolen_named_cursor_close(self): cur1 = self.conn.cursor() cur1.execute("DECLARE test CURSOR WITHOUT HOLD " @@ -475,7 +468,6 @@ class CursorTests(ConnectingTestCase): cur2 = self.conn.cursor('test') cur2.close() - @skip_before_postgres(8, 0) def test_scroll(self): cur = self.conn.cursor() cur.execute("select generate_series(0,9)") @@ -509,7 +501,6 @@ class CursorTests(ConnectingTestCase): self.assertRaises((IndexError, psycopg2.ProgrammingError), cur.scroll, 1) - @skip_before_postgres(8, 0) def test_scroll_named(self): cur = self.conn.cursor('tmp', scrollable=True) cur.execute("select generate_series(0,9)") @@ -636,7 +627,6 @@ class CursorTests(ConnectingTestCase): self.assertEqual(victim_conn.closed, 2) - @skip_before_postgres(8, 2) def test_rowcount_on_executemany_returning(self): cur = self.conn.cursor() cur.execute("create table execmany(id serial primary key, data int)") diff --git a/tests/test_dates.py b/tests/test_dates.py index b9aac695..e1d69f64 100755 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -321,7 +321,6 @@ class DatetimeTests(ConnectingTestCase, CommonDatetimeTestsMixin): def test_type_roundtrip_interval_array(self): self._test_type_roundtrip_array(timedelta(seconds=30)) - @skip_before_postgres(8, 1) def test_time_24(self): t = self.execute("select '24:00'::time;") self.assertEqual(t, time(0, 0)) @@ -332,7 +331,6 @@ class DatetimeTests(ConnectingTestCase, CommonDatetimeTestsMixin): t = self.execute("select '24:00+05:30'::timetz;") self.assertEqual(t, time(0, 0, tzinfo=FixedOffsetTimezone(330))) - @skip_before_postgres(8, 1) def test_large_interval(self): t = self.execute("select '999999:00:00'::interval") self.assertEqual(total_seconds(t), 999999 * 60 * 60) diff --git a/tests/test_extras_dictcursor.py b/tests/test_extras_dictcursor.py index d4bb12f5..ee4e2555 100755 --- a/tests/test_extras_dictcursor.py +++ b/tests/test_extras_dictcursor.py @@ -25,8 +25,7 @@ from psycopg2.compat import lru_cache import psycopg2.extras from psycopg2.extras import NamedTupleConnection, NamedTupleCursor -from .testutils import ConnectingTestCase, skip_before_postgres, \ - skip_before_python, skip_from_python +from .testutils import ConnectingTestCase, skip_before_python, skip_from_python class _DictCursorBase(ConnectingTestCase): @@ -97,7 +96,6 @@ class ExtrasDictCursorTests(_DictCursorBase): self.failUnless(row['foo'] == 'qux') self.failUnless(row[0] == 'qux') - @skip_before_postgres(8, 0) def testDictCursorWithPlainCursorIterRowNumber(self): curs = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) self._testIterRowNumber(curs) @@ -128,12 +126,10 @@ class ExtrasDictCursorTests(_DictCursorBase): return row self._testWithNamedCursor(getter) - @skip_before_postgres(8, 2) def testDictCursorWithNamedCursorNotGreedy(self): curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.DictCursor) self._testNamedCursorNotGreedy(curs) - @skip_before_postgres(8, 0) def testDictCursorWithNamedCursorIterRowNumber(self): curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.DictCursor) self._testIterRowNumber(curs) @@ -246,7 +242,6 @@ class ExtrasDictCursorRealTests(_DictCursorBase): return row self._testWithPlainCursorReal(getter) - @skip_before_postgres(8, 0) def testDictCursorWithPlainCursorRealIterRowNumber(self): curs = self.conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) self._testIterRowNumber(curs) @@ -285,12 +280,10 @@ class ExtrasDictCursorRealTests(_DictCursorBase): return row self._testWithNamedCursorReal(getter) - @skip_before_postgres(8, 2) def testDictCursorRealWithNamedCursorNotGreedy(self): curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.RealDictCursor) self._testNamedCursorNotGreedy(curs) - @skip_before_postgres(8, 0) def testDictCursorRealWithNamedCursorIterRowNumber(self): curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.RealDictCursor) self._testIterRowNumber(curs) @@ -524,7 +517,6 @@ class NamedTupleCursorTest(ConnectingTestCase): self.assertEqual(rv.f3, 3) @skip_before_python(3) - @skip_before_postgres(8) def test_nonascii_name(self): curs = self.conn.cursor() curs.execute('select 1 as \xe5h\xe9') @@ -563,7 +555,6 @@ class NamedTupleCursorTest(ConnectingTestCase): finally: NamedTupleCursor._make_nt = f_orig - @skip_before_postgres(8, 0) def test_named(self): curs = self.conn.cursor('tmp') curs.execute("""select i from generate_series(0,9) i""") @@ -591,7 +582,6 @@ class NamedTupleCursorTest(ConnectingTestCase): recs = curs.fetchall() self.assertEqual(recs[0].i, 42) - @skip_before_postgres(8, 2) def test_not_greedy(self): curs = self.conn.cursor('tmp') curs.itersize = 2 @@ -605,7 +595,6 @@ class NamedTupleCursorTest(ConnectingTestCase): self.assert_(recs[1].ts - recs[0].ts < timedelta(seconds=0.005)) self.assert_(recs[2].ts - recs[1].ts > timedelta(seconds=0.0099)) - @skip_before_postgres(8, 0) def test_named_rownumber(self): curs = self.conn.cursor('tmp') # Only checking for dataset < itersize: diff --git a/tests/test_fast_executemany.py b/tests/test_fast_executemany.py index eaba029c..1af89e3a 100755 --- a/tests/test_fast_executemany.py +++ b/tests/test_fast_executemany.py @@ -107,7 +107,6 @@ class TestExecuteBatch(FastExecuteTestMixin, testutils.ConnectingTestCase): cur.execute("select id, val from testfast order by id") self.assertEqual(cur.fetchall(), [(i, i * 10) for i in range(25)]) - @testutils.skip_before_postgres(8, 0) def test_unicode(self): cur = self.conn.cursor() ext.register_type(ext.UNICODE, cur) @@ -135,7 +134,6 @@ class TestExecuteBatch(FastExecuteTestMixin, testutils.ConnectingTestCase): self.assertEqual(cur.fetchone(), (3, snowman)) -@testutils.skip_before_postgres(8, 2) class TestExecuteValues(FastExecuteTestMixin, testutils.ConnectingTestCase): def test_empty(self): cur = self.conn.cursor() diff --git a/tests/test_green.py b/tests/test_green.py index e56ce586..72bbb9fa 100755 --- a/tests/test_green.py +++ b/tests/test_green.py @@ -115,7 +115,6 @@ class GreenTestCase(ConnectingTestCase): curs.execute("select 1") self.assertEqual(curs.fetchone()[0], 1) - @skip_before_postgres(8, 2) def test_copy_no_hang(self): cur = self.conn.cursor() self.assertRaises(psycopg2.ProgrammingError, diff --git a/tests/test_ipaddress.py b/tests/test_ipaddress.py index ccbae291..b3865cff 100755 --- a/tests/test_ipaddress.py +++ b/tests/test_ipaddress.py @@ -49,7 +49,6 @@ class NetworkingTestCase(testutils.ConnectingTestCase): self.assert_(isinstance(obj, ip.IPv6Interface), repr(obj)) self.assertEquals(obj, ip.ip_interface('::ffff:102:300/128')) - @testutils.skip_before_postgres(8, 2) def test_inet_array_cast(self): cur = self.conn.cursor() psycopg2.extras.register_ipaddress(cur) @@ -88,7 +87,6 @@ class NetworkingTestCase(testutils.ConnectingTestCase): self.assert_(isinstance(obj, ip.IPv6Network), repr(obj)) self.assertEquals(obj, ip.ip_network('::ffff:102:300/128')) - @testutils.skip_before_postgres(8, 2) def test_cidr_array_cast(self): cur = self.conn.cursor() psycopg2.extras.register_ipaddress(cur) diff --git a/tests/test_lobject.py b/tests/test_lobject.py index cae344f4..dd0d2409 100755 --- a/tests/test_lobject.py +++ b/tests/test_lobject.py @@ -32,12 +32,9 @@ import psycopg2 import psycopg2.extensions import unittest from .testutils import (decorate_all_tests, skip_if_tpc_disabled, - skip_before_postgres, ConnectingTestCase, skip_if_green, slow) + ConnectingTestCase, skip_if_green, slow) -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") @@ -66,7 +63,6 @@ class LargeObjectTestCase(ConnectingTestCase): ConnectingTestCase.tearDown(self) -@skip_if_no_lo @skip_lo_if_green class LargeObjectTests(LargeObjectTestCase): def test_create(self): @@ -412,7 +408,6 @@ 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): @@ -477,7 +472,6 @@ 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 @@ -505,7 +499,6 @@ def skip_if_lo64(f): return skip_if_lo64_ -@skip_if_no_lo @skip_lo_if_green @skip_if_no_truncate @skip_if_lo64 diff --git a/tests/test_quote.py b/tests/test_quote.py index 42e90eb7..3ce36f2c 100755 --- a/tests/test_quote.py +++ b/tests/test_quote.py @@ -42,10 +42,9 @@ class QuotingTestCase(ConnectingTestCase): This test case checks that the E'' quotes are used whenever they are needed. The tests are expected to pass with all PostgreSQL server versions - (currently tested with 7.4 <= PG <= 8.3beta) and with any - 'standard_conforming_strings' server parameter value. - The tests also check that no warning is raised ('escape_string_warning' - should be on). + and with any 'standard_conforming_strings' server parameter value. The + tests also check that no warning is raised ('escape_string_warning' should + be on). https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS https://www.postgresql.org/docs/current/static/runtime-config-compatible.html @@ -198,7 +197,6 @@ class TestQuotedIdentifier(ConnectingTestCase): self.assertEqual(quote_ident('blah-blah', self.conn), '"blah-blah"') self.assertEqual(quote_ident('quote"inside', self.conn), '"quote""inside"') - @testutils.skip_before_postgres(8, 0) def test_unicode_ident(self): snowman = u"\u2603" quoted = '"' + snowman + '"' diff --git a/tests/test_sql.py b/tests/test_sql.py index 9089ae77..c29050f3 100755 --- a/tests/test_sql.py +++ b/tests/test_sql.py @@ -25,8 +25,7 @@ import datetime as dt import unittest -from .testutils import ( - ConnectingTestCase, skip_before_postgres, skip_copy_if_green, StringIO) +from .testutils import ConnectingTestCase, skip_copy_if_green, StringIO import psycopg2 from psycopg2 import sql @@ -152,7 +151,6 @@ class SqlFormatTests(ConnectingTestCase): [(10, 'a', 'b', 'c'), (20, 'd', 'e', 'f')]) @skip_copy_if_green - @skip_before_postgres(8, 2) def test_copy(self): cur = self.conn.cursor() cur.execute(""" diff --git a/tests/test_transaction.py b/tests/test_transaction.py index 25feba0b..aa798b33 100755 --- a/tests/test_transaction.py +++ b/tests/test_transaction.py @@ -25,7 +25,7 @@ import threading import unittest -from .testutils import ConnectingTestCase, skip_before_postgres, slow +from .testutils import ConnectingTestCase, slow import psycopg2 from psycopg2.extensions import ( @@ -238,7 +238,6 @@ class QueryCancellationTests(ConnectingTestCase): ConnectingTestCase.setUp(self) self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE) - @skip_before_postgres(8, 2) def test_statement_timeout(self): curs = self.conn.cursor() # Set a low statement timeout, then sleep for a longer period. diff --git a/tests/test_types_basic.py b/tests/test_types_basic.py index a6b7af03..94326848 100755 --- a/tests/test_types_basic.py +++ b/tests/test_types_basic.py @@ -235,7 +235,6 @@ class TypesBasicTests(ConnectingTestCase): self.assert_(isinstance(x[0], bytes)) self.assertEqual(x, [b'a', b'b', b'c']) - @testutils.skip_before_postgres(8, 2) def testArrayOfNulls(self): curs = self.conn.cursor() curs.execute(""" @@ -271,7 +270,6 @@ class TypesBasicTests(ConnectingTestCase): curs.execute("insert into na (boolaa) values (%s)", ([[True, None]],)) curs.execute("insert into na (boolaa) values (%s)", ([[None, None]],)) - @testutils.skip_before_postgres(8, 2) def testNestedArrays(self): curs = self.conn.cursor() for a in [ @@ -385,7 +383,6 @@ class TypesBasicTests(ConnectingTestCase): 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: @@ -400,7 +397,6 @@ class TypesBasicTests(ConnectingTestCase): a = self.execute("select '{1, 2, NULL}'::int4[]") self.assertEqual(a, [2, 4, 'nada']) - @testutils.skip_before_postgres(8, 2) def testNetworkArray(self): # we don't know these types, but we know their arrays a = self.execute("select '{192.168.0.1/24}'::inet[]") diff --git a/tests/test_types_extras.py b/tests/test_types_extras.py index 91e4a8ea..6d31755f 100755 --- a/tests/test_types_extras.py +++ b/tests/test_types_extras.py @@ -415,21 +415,7 @@ class HstoreTestCase(ConnectingTestCase): conn.close() -def skip_if_no_composite(f): - @wraps(f) - def skip_if_no_composite_(self): - if self.conn.info.server_version < 80000: - return self.skipTest( - "server version %s doesn't support composite types" - % self.conn.info.server_version) - - return f(self) - - return skip_if_no_composite_ - - class AdaptTypeTestCase(ConnectingTestCase): - @skip_if_no_composite def test_none_in_record(self): curs = self.conn.cursor() s = curs.mogrify("SELECT %s;", [(42, None)]) @@ -489,7 +475,6 @@ class AdaptTypeTestCase(ConnectingTestCase): '^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f")', [None, ''.join(map(chr, range(1, 128)))]) - @skip_if_no_composite def test_cast_composite(self): oid = self._create_type("type_isd", [('anint', 'integer'), ('astring', 'text'), ('adate', 'date')]) @@ -515,7 +500,6 @@ class AdaptTypeTestCase(ConnectingTestCase): self.assertEqual(v.astring, "hello") self.assertEqual(v.adate, date(2011, 1, 2)) - @skip_if_no_composite def test_empty_string(self): # issue #141 self._create_type("type_ss", [('s1', 'text'), ('s2', 'text')]) @@ -535,7 +519,6 @@ class AdaptTypeTestCase(ConnectingTestCase): ok(('', '')) ok((None, None)) - @skip_if_no_composite def test_cast_nested(self): self._create_type("type_is", [("anint", "integer"), ("astring", "text")]) @@ -556,7 +539,6 @@ class AdaptTypeTestCase(ConnectingTestCase): self.assertEqual(r, v) self.assertEqual(v.anotherpair.apair.astring, "hello") - @skip_if_no_composite def test_register_on_cursor(self): self._create_type("type_ii", [("a", "integer"), ("b", "integer")]) @@ -568,7 +550,6 @@ class AdaptTypeTestCase(ConnectingTestCase): curs2.execute("select (1,2)::type_ii") self.assertEqual(curs2.fetchone()[0], "(1,2)") - @skip_if_no_composite def test_register_on_connection(self): self._create_type("type_ii", [("a", "integer"), ("b", "integer")]) @@ -586,7 +567,6 @@ class AdaptTypeTestCase(ConnectingTestCase): conn1.close() conn2.close() - @skip_if_no_composite @restore_types def test_register_globally(self): self._create_type("type_ii", [("a", "integer"), ("b", "integer")]) @@ -606,7 +586,6 @@ class AdaptTypeTestCase(ConnectingTestCase): conn1.close() conn2.close() - @skip_if_no_composite def test_composite_namespace(self): curs = self.conn.cursor() curs.execute(""" @@ -625,7 +604,6 @@ class AdaptTypeTestCase(ConnectingTestCase): curs.execute("select (4,8)::typens.typens_ii") self.assertEqual(curs.fetchone()[0], (4, 8)) - @skip_if_no_composite @skip_before_postgres(8, 4) def test_composite_array(self): self._create_type("type_isd", @@ -648,7 +626,6 @@ class AdaptTypeTestCase(ConnectingTestCase): self.assertEqual(v[1][1], "world") self.assertEqual(v[1][2], date(2011, 1, 3)) - @skip_if_no_composite def test_wrong_schema(self): oid = self._create_type("type_ii", [("a", "integer"), ("b", "integer")]) c = CompositeCaster('type_ii', oid, [('a', 23), ('b', 23), ('c', 23)]) @@ -658,7 +635,6 @@ class AdaptTypeTestCase(ConnectingTestCase): self.assertRaises(psycopg2.DataError, curs.fetchone) @slow - @skip_if_no_composite @skip_before_postgres(8, 4) def test_from_tables(self): curs = self.conn.cursor() @@ -703,7 +679,6 @@ class AdaptTypeTestCase(ConnectingTestCase): self.assertEqual(r[0], (2, 'test2')) self.assertEqual(r[1], [(3, 'testc', 2), (4, 'testd', 2)]) - @skip_if_no_composite def test_non_dbapi_connection(self): self._create_type("type_ii", [("a", "integer"), ("b", "integer")]) @@ -725,7 +700,6 @@ class AdaptTypeTestCase(ConnectingTestCase): finally: conn.close() - @skip_if_no_composite def test_subclass(self): oid = self._create_type("type_isd", [('anint', 'integer'), ('astring', 'text'), ('adate', 'date')]) @@ -953,7 +927,6 @@ class JsonTestCase(ConnectingTestCase): self.assert_(s.startswith("'")) self.assert_(s.endswith("'")) - @skip_before_postgres(8, 2) def test_scs(self): cnn_on = self.connect(options="-c standard_conforming_strings=on") cur_on = cnn_on.cursor() diff --git a/tests/test_with.py b/tests/test_with.py index b8c043f6..fc875dbe 100755 --- a/tests/test_with.py +++ b/tests/test_with.py @@ -27,7 +27,7 @@ import psycopg2 import psycopg2.extensions as ext import unittest -from .testutils import ConnectingTestCase, skip_before_postgres +from .testutils import ConnectingTestCase class WithTestCase(ConnectingTestCase): @@ -216,7 +216,6 @@ class WithCursorTestCase(WithTestCase): else: self.fail("where is my exception?") - @skip_before_postgres(8, 2) def test_named_with_noop(self): with self.conn.cursor('named'): pass