@@ -157,41 +157,39 @@ def test_1104(self):
157157
158158 def test_1105 (self ):
159159 "1105 - connection to database with bad connect string"
160- self .assertRaisesRegex (
161- oracledb .DatabaseError ,
162- "^DPY-4000:|^DPY-4026:|^DPY-4027:|ORA-12154:" ,
163- oracledb .connect ,
164- test_env .get_main_user (),
165- )
166- self .assertRaisesRegex (
167- oracledb .DatabaseError ,
168- "^DPY-4000:|^DPY-4001:" ,
169- oracledb .connect ,
170- test_env .get_main_user () + "@" + test_env .get_connect_string (),
171- )
160+ with self .assertRaisesFullCode (
161+ "DPY-4000" , "DPY-4026" , "DPY-4027" , "ORA-12154"
162+ ):
163+ oracledb .connect (test_env .get_main_user ())
164+ with self .assertRaisesFullCode ("DPY-4000" , "DPY-4001" ):
165+ dsn = (
166+ test_env .get_main_user () + "@" + test_env .get_connect_string ()
167+ )
168+ oracledb .connect (dsn )
172169 errors = (
173- "^DPY-4000:|^DPY-4001:|^DPY-4017:|^ORA-12154:|^ORA-12521:|"
174- "^ORA-12262:"
175- )
176- self .assertRaisesRegex (
177- oracledb .DatabaseError ,
178- errors ,
179- oracledb .connect ,
180- test_env .get_main_user ()
181- + "@"
182- + test_env .get_connect_string ()
183- + "/"
184- + test_env .get_main_password (),
185- )
170+ "DPY-4000" ,
171+ "DPY-4001" ,
172+ "DPY-4017" ,
173+ "ORA-12154" ,
174+ "ORA-12521" ,
175+ "ORA-12262" ,
176+ )
177+ with self .assertRaisesFullCode (* errors ):
178+ dsn = (
179+ test_env .get_main_user ()
180+ + "@"
181+ + test_env .get_connect_string ()
182+ + "/"
183+ + test_env .get_main_password ()
184+ )
185+ oracledb .connect (dsn )
186186
187187 def test_1106 (self ):
188188 "1106 - connection to database with bad password"
189- self .assertRaisesRegex (
190- oracledb .DatabaseError ,
191- "^ORA-01017:" ,
192- test_env .get_connection ,
193- password = test_env .get_main_password () + "X" ,
194- )
189+ with self .assertRaisesFullCode ("ORA-01017" ):
190+ test_env .get_connection (
191+ password = test_env .get_main_password () + "X"
192+ )
195193
196194 @unittest .skipIf (test_env .get_is_drcp (), "not supported with DRCP" )
197195 def test_1107 (self ):
@@ -214,20 +212,10 @@ def test_1108(self):
214212 if self .is_on_oracle_cloud (conn ):
215213 self .skipTest ("passwords on Oracle Cloud are strictly controlled" )
216214 new_password = "1" * 1500
217- self .assertRaisesRegex (
218- oracledb .DatabaseError ,
219- "^ORA-01017:|^ORA-00988:" ,
220- conn .changepassword ,
221- test_env .get_main_password (),
222- new_password ,
223- )
224- self .assertRaisesRegex (
225- oracledb .DatabaseError ,
226- "^ORA-01017:|^ORA-28008:|^ORA-00988:" ,
227- conn .changepassword ,
228- "incorrect old password" ,
229- new_password ,
230- )
215+ with self .assertRaisesFullCode ("ORA-01017" , "ORA-00988" ):
216+ conn .changepassword (test_env .get_main_password (), new_password )
217+ with self .assertRaisesFullCode ("ORA-01017" , "ORA-00988" , "ORA-28008" ):
218+ conn .changepassword ("incorrect old password" , new_password )
231219
232220 @unittest .skipIf (test_env .get_is_drcp (), "not supported with DRCP" )
233221 def test_1109 (self ):
@@ -252,9 +240,8 @@ def test_1110(self):
252240 "1110 - confirm an exception is raised after closing a connection"
253241 conn = test_env .get_connection ()
254242 conn .close ()
255- self .assertRaisesRegex (
256- oracledb .InterfaceError , "^DPY-1001:" , conn .rollback
257- )
243+ with self .assertRaisesFullCode ("DPY-1001" ):
244+ conn .rollback ()
258245
259246 @unittest .skipIf (test_env .get_is_thin (), "not relevant for thin mode" )
260247 def test_1111 (self ):
@@ -277,9 +264,8 @@ def test_1111(self):
277264 self .assertEqual (fetched_int_value , int_value )
278265
279266 cursor .close ()
280- self .assertRaisesRegex (
281- oracledb .DatabaseError , "^DPI-1034:" , conn2 .close
282- )
267+ with self .assertRaisesFullCode ("DPI-1034" ):
268+ conn2 .close ()
283269 conn .close ()
284270
285271 def test_1112 (self ):
@@ -343,9 +329,8 @@ def test_1117(self):
343329 cursor .execute ("insert into TestTempTable (IntCol) values (1)" )
344330 conn .commit ()
345331 cursor .execute ("insert into TestTempTable (IntCol) values (2)" )
346- self .assertRaisesRegex (
347- oracledb .InterfaceError , "^DPY-1001:" , conn .ping
348- )
332+ with self .assertRaisesFullCode ("DPY-1001" ):
333+ conn .ping ()
349334 conn = test_env .get_connection ()
350335 cursor = conn .cursor ()
351336 cursor .execute ("select count(*) from TestTempTable" )
@@ -384,9 +369,8 @@ def test_1119(self):
384369 if test_env .get_client_version () >= (12 , 1 ):
385370 attr_names .append ("ltxid" )
386371 for name in attr_names :
387- self .assertRaisesRegex (
388- oracledb .InterfaceError , "^DPY-1001:" , getattr , conn , name
389- )
372+ with self .assertRaisesFullCode ("DPY-1001" ):
373+ getattr (conn , name )
390374
391375 def test_1120 (self ):
392376 "1120 - test connection ping makes a round trip"
@@ -544,9 +528,8 @@ def test_1124(self):
544528
545529 id_ = random .randint (0 , 2 ** 128 )
546530 xid = (0x1234 , "%032x" % id_ , "%032x" % 9 )
547- self .assertRaisesRegex (
548- oracledb .DatabaseError , "^ORA-24776:" , conn .begin , * xid
549- )
531+ with self .assertRaisesFullCode ("ORA-24776" ):
532+ conn .begin (* xid )
550533
551534 def test_1125 (self ):
552535 "1125 - single connection to database with multiple threads"
@@ -660,13 +643,8 @@ def test_1131(self):
660643 conn = test_env .get_connection ()
661644 conn .call_timeout = 500 # milliseconds
662645 self .assertEqual (conn .call_timeout , 500 )
663- self .assertRaisesRegex (
664- oracledb .DatabaseError ,
665- "^DPY-4011:|^DPY-4024:" ,
666- conn .cursor ().callproc ,
667- test_env .get_sleep_proc_name (),
668- [2 ],
669- )
646+ with self .assertRaisesFullCode ("DPY-4011" , "DPY-4024" ):
647+ conn .cursor ().callproc (test_env .get_sleep_proc_name (), [2 ])
670648
671649 def test_1132 (self ):
672650 "1132 - test Connection repr()"
@@ -705,23 +683,15 @@ def test_1134(self):
705683 "1134 - test error for invalid type for params and pool"
706684 pool = test_env .get_pool ()
707685 pool .close ()
708- self .assertRaisesRegex (
709- oracledb .InterfaceError ,
710- "^DPY-1002:" ,
711- test_env .get_connection ,
712- pool = pool ,
713- )
686+ with self .assertRaisesFullCode ("DPY-1002" ):
687+ test_env .get_connection (pool = pool )
714688 self .assertRaises (
715689 TypeError ,
716690 test_env .get_connection ,
717691 pool = "This isn't an instance of a pool" ,
718692 )
719- self .assertRaisesRegex (
720- oracledb .ProgrammingError ,
721- "^DPY-2025:" ,
722- oracledb .connect ,
723- params = {"number" : 7 },
724- )
693+ with self .assertRaisesFullCode ("DPY-2025" ):
694+ oracledb .connect (params = {"number" : 7 })
725695
726696 def test_1135 (self ):
727697 "1135 - test connection instance name"
@@ -765,13 +735,8 @@ def test_1137(self):
765735 conn .changepassword (new_password_1024 , original_password )
766736
767737 new_password_1025 = "a" * 1025
768- self .assertRaisesRegex (
769- oracledb .DatabaseError ,
770- "^ORA-28218:|^ORA-00972" ,
771- conn .changepassword ,
772- original_password ,
773- new_password_1025 ,
774- )
738+ with self .assertRaisesFullCode ("ORA-28218" , "ORA-00972" ):
739+ conn .changepassword (original_password , new_password_1025 )
775740
776741 def test_1138 (self ):
777742 "1138 - test getting db_name"
@@ -831,6 +796,16 @@ def test_1143(self):
831796 self .assertEqual (conn .username , test_env .get_main_user ())
832797 self .assertEqual (conn .proxy_user , proxy_user )
833798
799+ @unittest .skipIf (
800+ not test_env .get_is_thin (), "thick mode doesn't support SDU yet"
801+ )
802+ def test_1144 (self ):
803+ "1144 - test connection.sdu"
804+ conn = test_env .get_connection ()
805+ sdu = random .randint (512 , conn .sdu )
806+ conn = test_env .get_connection (sdu = sdu )
807+ self .assertEqual (conn .sdu , sdu )
808+
834809
835810if __name__ == "__main__" :
836811 test_env .run_test_cases ()
0 commit comments