Skip to content

Commit ab59c5f

Browse files
Test improvements.
1 parent 004e06f commit ab59c5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+235
-467
lines changed

tests/test_1000_module.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -27,7 +27,6 @@
2727
"""
2828

2929
import datetime
30-
import unittest
3130

3231
import oracledb
3332
import test_env
@@ -169,7 +168,7 @@ def test_1006(self):
169168
)
170169
self.assertIs(oracledb.version, oracledb.__version__)
171170

172-
@unittest.skipUnless(test_env.get_is_thin(), "not relevant for thick mode")
171+
@test_env.skip_unless_thin_mode()
173172
def test_1007(self):
174173
"1007 - test clientversion() fails without init_oracle_client()"
175174
with self.assertRaisesFullCode("DPY-2021"):

tests/test_1100_connection.py

Lines changed: 22 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import string
3131
import threading
3232
import time
33-
import unittest
3433

3534
import oracledb
3635
import test_env
@@ -84,7 +83,7 @@ def test_1100(self):
8483
)
8584
self.assertEqual(conn.thin, test_env.get_is_thin())
8685

87-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
86+
@test_env.skip_if_drcp()
8887
def test_1101(self):
8988
"1101 - test use of application context"
9089
namespace = "CLIENTCONTEXT"
@@ -175,7 +174,7 @@ def test_1106(self):
175174
password=test_env.get_main_password() + "X"
176175
)
177176

178-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
177+
@test_env.skip_if_drcp()
179178
def test_1107(self):
180179
"1107 - test changing password"
181180
conn = test_env.get_connection()
@@ -189,7 +188,7 @@ def test_1107(self):
189188
conn = test_env.get_connection(password=new_password)
190189
conn.changepassword(new_password, test_env.get_main_password())
191190

192-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
191+
@test_env.skip_if_drcp()
193192
def test_1108(self):
194193
"1108 - test changing password to an invalid value"
195194
conn = test_env.get_connection()
@@ -201,7 +200,7 @@ def test_1108(self):
201200
with self.assertRaisesFullCode("ORA-01017", "ORA-00988", "ORA-28008"):
202201
conn.changepassword("incorrect old password", new_password)
203202

204-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
203+
@test_env.skip_if_drcp()
205204
def test_1109(self):
206205
"1109 - test connecting with password containing / and @ symbols"
207206
conn = test_env.get_connection()
@@ -227,7 +226,7 @@ def test_1110(self):
227226
with self.assertRaisesFullCode("DPY-1001"):
228227
conn.rollback()
229228

230-
@unittest.skipIf(test_env.get_is_thin(), "not relevant for thin mode")
229+
@test_env.skip_unless_thick_mode()
231230
def test_1111(self):
232231
"1111 - test creating a connection using a handle"
233232
conn = test_env.get_connection()
@@ -370,10 +369,7 @@ def test_1120(self):
370369
self.conn.ping()
371370
self.assertRoundTrips(1)
372371

373-
@unittest.skipIf(
374-
test_env.get_is_thin(),
375-
"thin mode doesn't support two-phase commit yet",
376-
)
372+
@test_env.skip_unless_thick_mode()
377373
def test_1121(self):
378374
"1121 - test begin, prepare, cancel transaction"
379375
conn = test_env.get_connection()
@@ -395,10 +391,7 @@ def test_1121(self):
395391
(count,) = cursor.fetchone()
396392
self.assertEqual(count, 0)
397393

398-
@unittest.skipIf(
399-
test_env.get_is_thin(),
400-
"thin mode doesn't support two-phase commit yet",
401-
)
394+
@test_env.skip_unless_thick_mode()
402395
def test_1122(self):
403396
"1122 - test multiple transactions on the same connection"
404397
conn = test_env.get_connection()
@@ -438,10 +431,7 @@ def test_1122(self):
438431
cursor.execute("select IntCol, StringCol1 from TestTempTable")
439432
self.assertEqual(cursor.fetchall(), expected_rows)
440433

441-
@unittest.skipIf(
442-
test_env.get_is_thin(),
443-
"thin mode doesn't support two-phase commit yet",
444-
)
434+
@test_env.skip_unless_thick_mode()
445435
def test_1123(self):
446436
"1123 - test multiple global transactions on the same connection"
447437
conn = test_env.get_connection()
@@ -499,10 +489,7 @@ def test_1123(self):
499489
cursor.execute("select IntCol, StringCol1 from TestTempTable")
500490
self.assertEqual(cursor.fetchall(), expected_rows)
501491

502-
@unittest.skipIf(
503-
test_env.get_is_thin(),
504-
"thin mode doesn't support two-phase commit yet",
505-
)
492+
@test_env.skip_unless_thick_mode()
506493
def test_1124(self):
507494
"1124 - test creating global txn after a local txn"
508495
conn = test_env.get_connection()
@@ -562,7 +549,7 @@ def perform_cancel():
562549
(user,) = cursor.fetchone()
563550
self.assertEqual(user, test_env.get_main_user().upper())
564551

565-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
552+
@test_env.skip_if_drcp()
566553
def test_1127(self):
567554
"1127 - test changing password during connect"
568555
conn = test_env.get_connection()
@@ -625,7 +612,7 @@ def test_1130(self):
625612
cursor.callproc("dbms_output.get_line", (string_var, number_var))
626613
self.assertEqual(string_var.getvalue(), test_string)
627614

628-
@unittest.skipUnless(test_env.has_client_version(18), "unsupported client")
615+
@test_env.skip_unless_call_timeout_supported()
629616
def test_1131(self):
630617
"1131 - test connection call_timeout"
631618
conn = test_env.get_connection()
@@ -694,18 +681,15 @@ def test_1135(self):
694681
(instance_name,) = cursor.fetchone()
695682
self.assertEqual(conn.instance_name.upper(), instance_name)
696683

697-
@unittest.skipUnless(
698-
test_env.has_client_version(18), "not supported on this client"
699-
)
684+
@test_env.skip_unless_call_timeout_supported()
700685
def test_1136(self):
701686
"1136 - test deprecated attributes"
702687
conn = test_env.get_connection()
703688
conn.callTimeout = 500
704689
self.assertEqual(conn.callTimeout, 500)
705690

706-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
707-
@unittest.skipUnless(test_env.has_server_version(23), "unsupported server")
708-
@unittest.skipUnless(test_env.has_client_version(23), "unsupported client")
691+
@test_env.skip_if_drcp()
692+
@test_env.skip_unless_long_passwords_supported()
709693
def test_1137(self):
710694
"1137 - test maximum allowed length for password"
711695
conn = test_env.get_connection()
@@ -784,9 +768,7 @@ def test_1143(self):
784768
self.assertEqual(conn.username, test_env.get_main_user())
785769
self.assertEqual(conn.proxy_user, proxy_user)
786770

787-
@unittest.skipIf(
788-
not test_env.get_is_thin(), "thick mode doesn't support SDU yet"
789-
)
771+
@test_env.skip_unless_thin_mode()
790772
def test_1144(self):
791773
"1144 - test connection.sdu"
792774
conn = test_env.get_connection()
@@ -799,10 +781,7 @@ def test_1145(self):
799781
with self.assertRaisesFullCode("DPY-2023"):
800782
test_env.get_connection(conn_class=oracledb.ConnectionPool)
801783

802-
@unittest.skipUnless(
803-
test_env.get_is_thin(),
804-
"thick mode doesn't support program yet",
805-
)
784+
@test_env.skip_unless_thin_mode()
806785
def test_1146(self):
807786
"1146 - test passing program when creating a connection"
808787
sql = (
@@ -811,10 +790,7 @@ def test_1146(self):
811790
)
812791
self.__verify_connect_arg("program", "newprogram", sql)
813792

814-
@unittest.skipUnless(
815-
test_env.get_is_thin(),
816-
"thick mode doesn't support machine yet",
817-
)
793+
@test_env.skip_unless_thin_mode()
818794
def test_1147(self):
819795
"1147 - test passing machine when creating a connection"
820796
sql = (
@@ -823,10 +799,7 @@ def test_1147(self):
823799
)
824800
self.__verify_connect_arg("machine", "newmachine", sql)
825801

826-
@unittest.skipUnless(
827-
test_env.get_is_thin(),
828-
"thick mode doesn't support terminal yet",
829-
)
802+
@test_env.skip_unless_thin_mode()
830803
def test_1148(self):
831804
"1148 - test passing terminal when creating a connection"
832805
sql = (
@@ -835,10 +808,7 @@ def test_1148(self):
835808
)
836809
self.__verify_connect_arg("terminal", "newterminal", sql)
837810

838-
@unittest.skipUnless(
839-
test_env.get_is_thin(),
840-
"thick mode doesn't support osuser yet",
841-
)
811+
@test_env.skip_unless_thin_mode()
842812
def test_1149(self):
843813
"1149 - test passing osuser when creating a connection"
844814
sql = (
@@ -855,9 +825,7 @@ def test_1150(self):
855825
)
856826
self.__verify_connect_arg("driver_name", "newdriver", sql)
857827

858-
@unittest.skipUnless(
859-
test_env.get_is_thin(), "thick mode doesn't support session_id yet"
860-
)
828+
@test_env.skip_unless_thin_mode()
861829
def test_1151(self):
862830
"1151 - test getting session id"
863831
conn = test_env.get_connection()
@@ -866,9 +834,7 @@ def test_1151(self):
866834
(fetched_value,) = cursor.fetchone()
867835
self.assertEqual(conn.session_id, fetched_value)
868836

869-
@unittest.skipUnless(
870-
test_env.get_is_thin(), "thick mode doesn't support serial_num yet"
871-
)
837+
@test_env.skip_unless_thin_mode()
872838
def test_1152(self):
873839
"1152 - test getting session serial number"
874840
conn = test_env.get_connection()
@@ -879,10 +845,7 @@ def test_1152(self):
879845
(fetched_value,) = cursor.fetchone()
880846
self.assertEqual(conn.serial_num, fetched_value)
881847

882-
@unittest.skipUnless(
883-
test_env.get_is_thin(),
884-
"thick mode doesn't support registered protocols",
885-
)
848+
@test_env.skip_unless_thin_mode()
886849
def test_1153(self):
887850
"1153 - test passed params in hook with standalone connection"
888851
sdu = 4096

tests/test_1600_dml_returning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def test_1622(self):
526526
self.cursor.execute(sql, in_val=25, out_val=out_val)
527527
self.assertEqual(out_val.getvalue(), [25])
528528

529-
@unittest.skipUnless(test_env.get_is_thin(), "cannot be checked")
529+
@test_env.skip_unless_thin_mode()
530530
def test_1623(self):
531531
"1623 - execute DML returning with duplicated binds"
532532
self.cursor.execute("truncate table TestTempTable")

tests/test_1700_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def test_1708(self):
197197
self.assertEqual(error_obj.full_code, f"ORA-{code}")
198198
self.assertTrue("Help:" not in error_obj.message)
199199

200-
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
200+
@test_env.skip_if_drcp()
201201
def test_1709(self):
202202
"1709 - error from killed connection is deemed recoverable"
203203
admin_conn = test_env.get_admin_connection()

tests/test_2200_number_var.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"""
2828

2929
import decimal
30-
import unittest
3130

3231
import oracledb
3332
import test_env
@@ -74,9 +73,7 @@ def setUp(self):
7473
self.raw_data.append(data_tuple)
7574
self.data_by_key[i] = data_tuple
7675

77-
@unittest.skipUnless(
78-
test_env.has_client_version(12, 1), "not supported on this client"
79-
)
76+
@test_env.skip_unless_plsql_boolean_supported()
8077
def test_2200(self):
8178
"2200 - test binding in a boolean"
8279
result = self.cursor.callfunc(

tests/test_2300_object_var.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import datetime
3030
import decimal
31-
import unittest
3231

3332
import oracledb
3433
import test_env
@@ -662,13 +661,13 @@ def test_2327(self):
662661
)
663662
self.assertEqual(result, 7146445847327)
664663

665-
@unittest.skipIf(test_env.get_is_thin(), "thin mode supports xmltype")
664+
@test_env.skip_unless_thick_mode()
666665
def test_2328(self):
667666
"2328 - test object with unknown type in one of its attributes"
668667
typ = self.conn.gettype("UDT_OBJECTWITHXMLTYPE")
669668
self.assertEqual(typ.attributes[1].type, oracledb.DB_TYPE_UNKNOWN)
670669

671-
@unittest.skipIf(test_env.get_is_thin(), "thin mode supports xmltype")
670+
@test_env.skip_unless_thick_mode()
672671
def test_2329(self):
673672
"2329 - test object with unknown type as the element type"
674673
typ = self.conn.gettype("UDT_XMLTYPEARRAY")
@@ -813,9 +812,7 @@ def test_2338(self):
813812
result = [i for i in obj]
814813
self.assertEqual(result, [5, 10, 15])
815814

816-
@unittest.skipUnless(
817-
test_env.get_is_thin(), "thick mode does not support xmltype"
818-
)
815+
@test_env.skip_unless_thin_mode()
819816
def test_2339(self):
820817
"2339 - test fetching an object containing an XmlType instance"
821818
num_val = 2339

0 commit comments

Comments
 (0)