Skip cancel tests on CockroachDB

One test moved to the async tests module, as it really belongs there.
This commit is contained in:
Daniele Varrazzo 2020-07-21 02:15:53 +01:00
parent ee34198bf6
commit f8c1cff6a3
3 changed files with 12 additions and 8 deletions

View File

@ -532,6 +532,11 @@ class AsyncTests(ConnectingTestCase):
else: else:
self.fail("No notification received") self.fail("No notification received")
def test_close(self):
self.conn.close()
self.assertTrue(self.conn.closed)
self.assertTrue(self.conn.async_)
def test_suite(): def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__) return unittest.TestLoader().loadTestsFromName(__name__)

View File

@ -34,12 +34,16 @@ from psycopg2 import extras
from .testconfig import dsn from .testconfig import dsn
import unittest import unittest
from .testutils import ConnectingTestCase, skip_before_postgres, slow from .testutils import ConnectingTestCase, skip_before_postgres, slow
from .testutils import crdb_version
class CancelTests(ConnectingTestCase): class CancelTests(ConnectingTestCase):
def setUp(self): def setUp(self):
ConnectingTestCase.setUp(self) ConnectingTestCase.setUp(self)
# here, instead of a decorator, to avoid creating the temp table
if crdb_version(self.conn) is not None:
self.skipTest("cancel not supported on CockroachDB")
cur = self.conn.cursor() cur = self.conn.cursor()
cur.execute(''' cur.execute('''
@ -106,11 +110,6 @@ class CancelTests(ConnectingTestCase):
extras.wait_select(async_conn) extras.wait_select(async_conn)
self.assertEqual(cur.fetchall(), [(1, )]) self.assertEqual(cur.fetchall(), [(1, )])
def test_async_connection_cancel(self):
async_conn = psycopg2.connect(dsn, async_=True)
async_conn.close()
self.assertTrue(async_conn.closed)
def test_suite(): def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__) return unittest.TestLoader().loadTestsFromName(__name__)

View File

@ -409,13 +409,13 @@ def skip_if_windows(cls):
def crdb_version(conn, __crdb_version=[]): def crdb_version(conn, __crdb_version=[]):
""" """
Return the CockroachDB version if that's the db testing, else None. Return the CockroachDB version if that's the db being tested, else None.
Return the number as an integer similar to PQserverVersion: return Return the number as an integer similar to PQserverVersion: return
v20.1.3 as 200103. v20.1.3 as 200103.
Assume all the connections are on the same db: return a chached result on Assume all the connections are on the same db: return a cached result on
following runs. following calls.
""" """
if __crdb_version: if __crdb_version: