Skip to content

Commit e2344c1

Browse files
Simplify tests.
1 parent 0304898 commit e2344c1

19 files changed

+73
-24
lines changed

tests/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,30 @@ def run_sql_script(self, conn, script_name, **kwargs):
664664
prev_obj_type = obj_type
665665
print(" %s/%s %s" % (line_num, position, text))
666666

667+
def skip_unless_client_version(self, major_version, minor_version=0):
668+
"""
669+
Skips the test unless the specified client version or higher is being
670+
used.
671+
"""
672+
if not self.has_client_version(major_version, minor_version):
673+
if minor_version == 0:
674+
version = str(major_version)
675+
else:
676+
version = f"{major_version}.{minor_version}"
677+
pytest.skip(f"requires Oracle Client {version} or higher")
678+
679+
def skip_unless_server_version(self, major_version, minor_version=0):
680+
"""
681+
Skips the test unless the specified server version or higher is being
682+
used.
683+
"""
684+
if not self.has_server_version(major_version, minor_version):
685+
if minor_version == 0:
686+
version = str(major_version)
687+
else:
688+
version = f"{major_version}.{minor_version}"
689+
pytest.skip(f"requires Oracle Database {version} or higher")
690+
667691

668692
@pytest.fixture
669693
def admin_conn(test_env):

tests/ext/test_ext_1400_inband_notify.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
@pytest.fixture(scope="module", autouse=True)
3535
def setup_user(test_env):
36+
test_env.skip_unless_server_version(19)
3637
user = test_env.main_user
3738
with test_env.get_admin_connection() as admin_conn:
3839
with admin_conn.cursor() as cursor:

tests/ext/test_ext_1500_pool_grow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
def test_ext_1500(skip_unless_run_long_tests, test_env):
3535
"E1500 - test static pool grows back to the min after sessions killed"
36+
test_env.skip_unless_client_version(19)
3637
pool = test_env.get_pool(min=5, max=5, increment=1, ping_interval=0)
3738
conns = [pool.acquire() for i in range(5)]
3839
with test_env.get_admin_connection() as admin_conn:

tests/ext/test_ext_1800_inband_notif_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def module_checks(anyio_backend, skip_unless_thin_mode):
4545

4646
@pytest.fixture(scope="module", autouse=True)
4747
def setup_user(test_env):
48+
test_env.skip_unless_server_version(19)
4849
user = test_env.main_user
4950
with test_env.get_admin_connection() as admin_conn:
5051
with admin_conn.cursor() as cursor:

tests/sql/create_schema.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,6 @@ insert into &main_user..TestJsonCols values (1,
664664
'[1, 2, 3]', '[4, 5, 6]', utl_raw.cast_to_raw('[7, 8, 9]'))
665665
/
666666

667-
insert into &main_user..TestJsonCols values (2,
668-
'null', empty_clob(), empty_blob())
669-
/
670-
671667
commit
672668
/
673669

tests/sql/create_schema_21.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ create table &main_user..TestOsonCols (
4444
)
4545
/
4646

47+
insert into &main_user..TestJsonCols values (2,
48+
'null', empty_clob(), empty_blob())
49+
/
50+
4751
begin
4852
dbms_aqadm.create_queue_table('&main_user..JSON_QUEUE_TAB', 'JSON');
4953
dbms_aqadm.create_queue('&main_user..TEST_JSON_QUEUE',

tests/test_1600_dml_returning.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import datetime
3030

3131
import oracledb
32+
import pytest
3233

3334

3435
def test_1600(cursor):
@@ -601,8 +602,10 @@ def test_1625(conn, cursor):
601602

602603

603604
# blocked by bug 37741324 in thick mode
604-
def test_1626(skip_unless_thin_mode, conn, cursor):
605+
def test_1626(skip_unless_thin_mode, conn, cursor, test_env):
605606
"1626 - test DML returning with multiple DbObjects returned"
607+
if not test_env.has_server_version(21):
608+
pytest.skip("awaiting fix for bug 37756810")
606609
arrays = [
607610
(1626, 1627, 1628),
608611
(1629, 1630, 1631),

tests/test_1900_lob_var.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,9 @@ def test_1920(conn, cursor, test_env):
458458
assert lob.read() == supplemental_chars
459459

460460

461-
def test_1921(cursor):
461+
def test_1921(cursor, test_env):
462462
"1921 - test automatic conversion to CLOB for PL/SQL"
463+
test_env.skip_unless_server_version(12, 2)
463464
var = cursor.var(str, outconverter=lambda v: v[-15:])
464465
var.setvalue(0, "A" * 50000)
465466
cursor.execute(
@@ -477,8 +478,9 @@ def test_1921(cursor):
477478
assert var.getvalue() == "A" * 10 + "B" * 5
478479

479480

480-
def test_1922(cursor):
481+
def test_1922(cursor, test_env):
481482
"1922 - test automatic conversion to NCLOB for PL/SQL"
483+
test_env.skip_unless_server_version(12, 2)
482484
var = cursor.var(oracledb.DB_TYPE_NCHAR, outconverter=lambda v: v[-12:])
483485
var.setvalue(0, "N" * 51234)
484486
cursor.execute(
@@ -496,8 +498,9 @@ def test_1922(cursor):
496498
assert var.getvalue() == "N" * 5 + "P" * 7
497499

498500

499-
def test_1923(cursor):
501+
def test_1923(cursor, test_env):
500502
"1923 - test automatic conversion to BLOB for PL/SQL"
503+
test_env.skip_unless_server_version(12, 2)
501504
var = cursor.var(bytes, outconverter=lambda v: v[-14:])
502505
var.setvalue(0, b"L" * 52345)
503506
cursor.execute(

tests/test_2300_object_var.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,9 @@ def test_2341(test_env):
870870
conn.gettype(f"{main_user}.UDT_OBJECTARRAY")
871871

872872

873-
def test_2342(conn, cursor):
873+
def test_2342(conn, cursor, test_env):
874874
"2342 - test nested records"
875+
test_env.skip_unless_server_version(21)
875876
options = [(None, None), (1, None), (None, 2), (1, 2)]
876877
typ = conn.gettype("PKG_TESTNESTEDRECORDS.UDT_OUTER")
877878
for option in options:

tests/test_2400_pool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ def test_2410(skip_unless_thick_mode, test_env):
428428

429429
def test_2411(skip_unless_thick_mode, test_env):
430430
"2411 - test PL/SQL session callbacks"
431-
if not test_env.has_client_version(12, 2):
432-
pytest.skip("PL/SQL session callbacks not supported before 12.2")
431+
test_env.skip_unless_client_version(12, 2)
433432
callback = "pkg_SessionCallback.TheCallback"
434433
pool = test_env.get_pool(
435434
min=2,
@@ -673,6 +672,7 @@ def session_callback(cls, conn, requested_tag):
673672

674673
def test_2424(skip_if_drcp, admin_conn, test_env):
675674
"2424 - drop the pooled connection on receiving dead connection error"
675+
test_env.skip_unless_server_version(19)
676676
pool = test_env.get_pool(min=2, max=2, increment=2)
677677

678678
# acquire connections from the pool and kill all the sessions
@@ -767,6 +767,7 @@ def test_2430(test_env):
767767

768768
def test_2431(test_env):
769769
"2431 - verify that connection with different cclass is reused"
770+
test_env.skip_unless_server_version(19)
770771
cclass = "cclass2431"
771772
pool = test_env.get_pool(min=1, max=1)
772773
# ignore the first acquire which, depending on the speed with which the
@@ -1044,6 +1045,7 @@ def test_2456(test_env):
10441045

10451046
def test_2457(skip_if_drcp, test_env):
10461047
"2457 - ping pooled connection on receiving dead connection error"
1048+
test_env.skip_unless_server_version(18)
10471049
admin_conn = test_env.get_admin_connection()
10481050
pool = test_env.get_pool(min=1, max=1, ping_interval=0)
10491051

0 commit comments

Comments
 (0)