Added missing reasons for crdb skip

Added check to make sure a reason must be passed.
This commit is contained in:
Daniele Varrazzo 2020-08-17 21:27:25 +01:00
parent 513b0019b1
commit 6d8382b7ed
3 changed files with 10 additions and 7 deletions

View File

@ -355,7 +355,7 @@ class AsyncTests(ConnectingTestCase):
self.assertEquals(cur.fetchone()[0], 1)
@slow
@skip_if_crdb
@skip_if_crdb("notify")
def test_notify(self):
cur = self.conn.cursor()
sync_cur = self.sync_conn.cursor()
@ -433,7 +433,7 @@ class AsyncTests(ConnectingTestCase):
self.wait(cur2)
self.assertEquals(cur2.fetchone()[0], 1)
@skip_if_crdb
@skip_if_crdb("notice")
def test_notices(self):
del self.conn.notices[:]
cur = self.conn.cursor()
@ -458,7 +458,7 @@ class AsyncTests(ConnectingTestCase):
self.wait(self.conn)
self.assertEqual(cur.fetchone(), (42,))
@skip_if_crdb
@skip_if_crdb("copy")
def test_async_connection_error_message(self):
try:
cnn = psycopg2.connect('dbname=thisdatabasedoesntexist', async_=True)
@ -476,7 +476,7 @@ class AsyncTests(ConnectingTestCase):
self.assertRaises(psycopg2.ProgrammingError, self.wait, self.conn)
@slow
@skip_if_crdb
@skip_if_crdb("notice")
@skip_before_postgres(9, 0)
def test_non_block_after_notification(self):
from select import select
@ -510,7 +510,7 @@ class AsyncTests(ConnectingTestCase):
def test_poll_noop(self):
self.conn.poll()
@skip_if_crdb
@skip_if_crdb("notify")
@skip_before_postgres(9, 0)
def test_poll_conn_for_notification(self):
with self.conn.cursor() as cur:

View File

@ -173,7 +173,7 @@ class TypesBasicTests(ConnectingTestCase):
curs.execute("select col from array_test where id = 2")
self.assertEqual(curs.fetchone()[0], [])
@skip_if_crdb
@skip_if_crdb("nested array")
@testutils.skip_before_postgres(8, 4)
def testNestedEmptyArray(self):
# issue #788
@ -276,7 +276,7 @@ class TypesBasicTests(ConnectingTestCase):
curs.execute("insert into na (boolaa) values (%s)", ([[True, None]],))
curs.execute("insert into na (boolaa) values (%s)", ([[None, None]],))
@skip_if_crdb
@skip_if_crdb("nested array")
@testutils.skip_before_postgres(8, 2)
def testNestedArrays(self):
curs = self.conn.cursor()

View File

@ -449,6 +449,9 @@ def skip_if_crdb(reason, conn=None):
Or as a normal function if the *conn* argument is passed.
"""
if not isinstance(reason, str):
raise TypeError("reason should be a string, got %r instead" % reason)
if conn is not None:
if crdb_version(conn) is not None:
raise unittest.SkipTest("not supported on CockroachDB: %s" % reason)