From c8697e6c67b85af69a7dd9d4350447a66530eb5e Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 22 Jul 2020 02:43:19 +0100 Subject: Several other tests skipped for CockroachDB The only remaining test modules in this branch are test_types_basic/extra. --- tests/test_green.py | 3 +++ tests/test_ipaddress.py | 2 ++ tests/test_lobject.py | 15 ++++++--------- tests/test_module.py | 6 +++++- tests/test_notify.py | 3 ++- tests/test_quote.py | 4 +++- tests/test_sql.py | 4 +++- tests/test_transaction.py | 7 +++++++ tests/test_with.py | 4 +++- 9 files changed, 34 insertions(+), 14 deletions(-) diff --git a/tests/test_green.py b/tests/test_green.py index e56ce58..49f6cf7 100755 --- a/tests/test_green.py +++ b/tests/test_green.py @@ -33,6 +33,7 @@ import psycopg2.extras from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE from .testutils import ConnectingTestCase, skip_before_postgres, slow +from .testutils import skip_if_crdb class ConnectionStub(object): @@ -122,6 +123,7 @@ class GreenTestCase(ConnectingTestCase): cur.execute, "copy (select 1) to stdout") @slow + @skip_if_crdb @skip_before_postgres(9, 0) def test_non_block_after_notification(self): def wait(conn): @@ -216,6 +218,7 @@ class CallbackErrorTestCase(ConnectingTestCase): self.fail("you should have had a success or an error by now") + @skip_if_crdb def test_errors_named_cursor(self): for i in range(100): self.to_error = None diff --git a/tests/test_ipaddress.py b/tests/test_ipaddress.py index ccbae29..afd09b3 100755 --- a/tests/test_ipaddress.py +++ b/tests/test_ipaddress.py @@ -71,6 +71,7 @@ class NetworkingTestCase(testutils.ConnectingTestCase): cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')]) self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') + @testutils.skip_if_crdb def test_cidr_cast(self): cur = self.conn.cursor() psycopg2.extras.register_ipaddress(cur) @@ -88,6 +89,7 @@ class NetworkingTestCase(testutils.ConnectingTestCase): self.assert_(isinstance(obj, ip.IPv6Network), repr(obj)) self.assertEquals(obj, ip.ip_network('::ffff:102:300/128')) + @testutils.skip_if_crdb @testutils.skip_before_postgres(8, 2) def test_cidr_array_cast(self): cur = self.conn.cursor() diff --git a/tests/test_lobject.py b/tests/test_lobject.py index cae344f..619bf76 100755 --- a/tests/test_lobject.py +++ b/tests/test_lobject.py @@ -32,13 +32,14 @@ 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) + skip_before_postgres, ConnectingTestCase, skip_if_green, skip_if_crdb, 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") +def skip_if_no_lo(f): + f = skip_before_postgres(8, 1, "large objects only supported from PG 8.1")(f) + f = skip_if_green("libpq doesn't support LO in async mode")(f) + f = skip_if_crdb(f) + return f class LargeObjectTestCase(ConnectingTestCase): @@ -67,7 +68,6 @@ class LargeObjectTestCase(ConnectingTestCase): @skip_if_no_lo -@skip_lo_if_green class LargeObjectTests(LargeObjectTestCase): def test_create(self): lo = self.conn.lobject() @@ -413,7 +413,6 @@ def skip_if_no_truncate(f): @skip_if_no_lo -@skip_lo_if_green @skip_if_no_truncate class LargeObjectTruncateTests(LargeObjectTestCase): def test_truncate(self): @@ -478,7 +477,6 @@ def skip_if_no_lo64(f): @skip_if_no_lo -@skip_lo_if_green @skip_if_no_truncate @skip_if_no_lo64 class LargeObject64Tests(LargeObjectTestCase): @@ -506,7 +504,6 @@ def skip_if_lo64(f): @skip_if_no_lo -@skip_lo_if_green @skip_if_no_truncate @skip_if_lo64 class LargeObjectNot64Tests(LargeObjectTestCase): diff --git a/tests/test_module.py b/tests/test_module.py index 416e623..2e8b753 100755 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -32,7 +32,7 @@ from weakref import ref import unittest from .testutils import (skip_before_postgres, - ConnectingTestCase, skip_copy_if_green, slow, StringIO) + ConnectingTestCase, skip_copy_if_green, skip_if_crdb, slow, StringIO) import psycopg2 @@ -216,6 +216,7 @@ class ExceptionsTestCase(ConnectingTestCase): gc.collect() assert(w() is None) + @skip_if_crdb @skip_copy_if_green def test_diagnostics_copy(self): f = StringIO() @@ -244,6 +245,7 @@ class ExceptionsTestCase(ConnectingTestCase): self.assertEqual(diag1.sqlstate, '42601') self.assertEqual(diag2.sqlstate, '42P01') + @skip_if_crdb def test_diagnostics_from_commit(self): cur = self.conn.cursor() cur.execute(""" @@ -259,6 +261,7 @@ class ExceptionsTestCase(ConnectingTestCase): e = exc self.assertEqual(e.diag.sqlstate, '23503') + @skip_if_crdb @skip_before_postgres(9, 3) def test_9_3_diagnostics(self): cur = self.conn.cursor() @@ -299,6 +302,7 @@ class ExceptionsTestCase(ConnectingTestCase): self.assertEqual(e.pgcode, e1.pgcode) self.assert_(e1.cursor is None) + @skip_if_crdb def test_pickle_connection_error(self): # segfaults on psycopg 2.5.1 - see ticket #170 try: diff --git a/tests/test_notify.py b/tests/test_notify.py index 51865e6..ace288b 100755 --- a/tests/test_notify.py +++ b/tests/test_notify.py @@ -29,7 +29,7 @@ from collections import deque import psycopg2 from psycopg2 import extensions from psycopg2.extensions import Notify -from .testutils import ConnectingTestCase, slow +from .testutils import ConnectingTestCase, skip_if_crdb, slow from .testconfig import dsn import sys @@ -38,6 +38,7 @@ import select from subprocess import Popen, PIPE +@skip_if_crdb class NotifiesTests(ConnectingTestCase): def autocommit(self, conn): diff --git a/tests/test_quote.py b/tests/test_quote.py index 42e90eb..7b4b1de 100755 --- a/tests/test_quote.py +++ b/tests/test_quote.py @@ -25,7 +25,7 @@ from . import testutils import unittest -from .testutils import ConnectingTestCase, unichr, PY2 +from .testutils import ConnectingTestCase, skip_if_crdb, unichr, PY2 import psycopg2 import psycopg2.extensions @@ -121,6 +121,7 @@ class QuotingTestCase(ConnectingTestCase): self.assertEqual(res, data) self.assert_(not self.conn.notices) + @skip_if_crdb def test_latin1(self): self.conn.set_client_encoding('LATIN1') curs = self.conn.cursor() @@ -146,6 +147,7 @@ class QuotingTestCase(ConnectingTestCase): self.assertEqual(res, data) self.assert_(not self.conn.notices) + @skip_if_crdb def test_koi8(self): self.conn.set_client_encoding('KOI8') curs = self.conn.cursor() diff --git a/tests/test_sql.py b/tests/test_sql.py index 9089ae7..8a732fe 100755 --- a/tests/test_sql.py +++ b/tests/test_sql.py @@ -26,7 +26,8 @@ import datetime as dt import unittest from .testutils import ( - ConnectingTestCase, skip_before_postgres, skip_copy_if_green, StringIO) + ConnectingTestCase, skip_before_postgres, skip_copy_if_green, StringIO, + skip_if_crdb) import psycopg2 from psycopg2 import sql @@ -151,6 +152,7 @@ class SqlFormatTests(ConnectingTestCase): self.assertEqual(cur.fetchall(), [(10, 'a', 'b', 'c'), (20, 'd', 'e', 'f')]) + @skip_if_crdb @skip_copy_if_green @skip_before_postgres(8, 2) def test_copy(self): diff --git a/tests/test_transaction.py b/tests/test_transaction.py index 25feba0..bc4fef0 100755 --- a/tests/test_transaction.py +++ b/tests/test_transaction.py @@ -26,18 +26,22 @@ import threading import unittest from .testutils import ConnectingTestCase, skip_before_postgres, slow +from .testutils import crdb_version, skip_if_crdb import psycopg2 from psycopg2.extensions import ( ISOLATION_LEVEL_SERIALIZABLE, STATUS_BEGIN, STATUS_READY) +@skip_if_crdb class TransactionTests(ConnectingTestCase): def setUp(self): ConnectingTestCase.setUp(self) self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE) curs = self.conn.cursor() + if crdb_version(self.conn) is not None: + self.skipTest("features not supported on CockroachDB") curs.execute(''' CREATE TEMPORARY TABLE table1 ( id int PRIMARY KEY @@ -92,6 +96,7 @@ class TransactionTests(ConnectingTestCase): self.assertEqual(curs.fetchone()[0], 1) +@skip_if_crdb class DeadlockSerializationTests(ConnectingTestCase): """Test deadlock and serialization failure errors.""" @@ -102,6 +107,8 @@ class DeadlockSerializationTests(ConnectingTestCase): def setUp(self): ConnectingTestCase.setUp(self) + if crdb_version(self.conn) is not None: + self.skipTest("features not supported on CockroachDB") curs = self.conn.cursor() # Drop table if it already exists diff --git a/tests/test_with.py b/tests/test_with.py index b8c043f..c58ea92 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, skip_before_postgres, skip_if_crdb class WithTestCase(ConnectingTestCase): @@ -203,6 +203,7 @@ class WithCursorTestCase(WithTestCase): self.assert_(curs.closed) self.assert_(closes) + @skip_if_crdb def test_exception_swallow(self): # bug #262: __exit__ calls cur.close() that hides the exception # with another error. @@ -216,6 +217,7 @@ class WithCursorTestCase(WithTestCase): else: self.fail("where is my exception?") + @skip_if_crdb @skip_before_postgres(8, 2) def test_named_with_noop(self): with self.conn.cursor('named'): -- cgit v1.2.1