Skip to content

Commit d014f86

Browse files
Simplify extended suite test conditions.
1 parent 4001b93 commit d014f86

9 files changed

+44
-63
lines changed

tests/ext/test_env.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 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
@@ -29,6 +29,7 @@
2929

3030
import configparser
3131
import os
32+
import unittest
3233

3334
dir_name = os.path.dirname(os.path.dirname(__file__))
3435
file_name = os.path.join(dir_name, os.path.basename(__file__))
@@ -73,3 +74,24 @@ def get_extended_config_str(name, fallback=None):
7374
return _extended_config.parser.get(
7475
_extended_config.section_name, name, fallback=fallback
7576
)
77+
78+
79+
def skip_unless_has_orapki():
80+
return unittest.skipUnless(
81+
get_extended_config_bool("has_orapki"),
82+
"extended configuration has_orapki is disabled",
83+
)
84+
85+
86+
def skip_unless_local_database():
87+
return unittest.skipUnless(
88+
get_extended_config_bool("local_database"),
89+
"extended configuration local_database is disabled",
90+
)
91+
92+
93+
def skip_unless_run_long_tests():
94+
return unittest.skipUnless(
95+
get_extended_config_bool("run_long_tests"),
96+
"extended configuration run_long_tests is disabled",
97+
)

tests/ext/test_ext_1000_pool_shrink.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828
"""
2929

3030
import time
31-
import unittest
3231

3332
import test_env
3433

3534

36-
@unittest.skipUnless(
37-
test_env.get_extended_config_bool("run_long_tests"),
38-
"extended configuration run_long_tests is disabled",
39-
)
35+
@test_env.skip_unless_run_long_tests()
4036
class TestCase(test_env.BaseTestCase):
4137
def test_ext_1000(self):
4238
"E1000 - test pool timeout with simple acquire after waiting"
@@ -62,7 +58,7 @@ def test_ext_1001(self):
6258
conn = pool.acquire()
6359
self.assertEqual(pool.opened, 3)
6460

65-
@unittest.skipUnless(test_env.get_is_thin(), "doesn't occur in thick mode")
61+
@test_env.skip_unless_thin_mode()
6662
def test_ext_1002(self):
6763
"E1002 - test pool timeout shrinks to min on pool inactivity"
6864
pool = test_env.get_pool(min=3, max=10, increment=2, timeout=4)
@@ -73,7 +69,7 @@ def test_ext_1002(self):
7369
time.sleep(6)
7470
self.assertEqual(pool.opened, 3)
7571

76-
@unittest.skipUnless(test_env.get_is_thin(), "doesn't occur in thick mode")
72+
@test_env.skip_unless_thin_mode()
7773
def test_ext_1003(self):
7874
"E1003 - test pool timeout eliminates extra connections on inactivity"
7975
pool = test_env.get_pool(min=4, max=10, increment=4, timeout=3)
@@ -85,7 +81,7 @@ def test_ext_1003(self):
8581
self.assertEqual(pool.opened, 5)
8682
del conns
8783

88-
@unittest.skipUnless(test_env.get_is_thin(), "doesn't occur in thick mode")
84+
@test_env.skip_unless_thin_mode()
8985
def test_ext_1004(self):
9086
"E1004 - test pool max_lifetime_session on release"
9187
pool = test_env.get_pool(
@@ -101,7 +97,7 @@ def test_ext_1004(self):
10197
time.sleep(2)
10298
self.assertEqual(pool.opened, 4)
10399

104-
@unittest.skipUnless(test_env.get_is_thin(), "doesn't occur in thick mode")
100+
@test_env.skip_unless_thin_mode()
105101
def test_ext_1005(self):
106102
"E1005 - test pool max_lifetime_session on acquire"
107103
pool = test_env.get_pool(

tests/ext/test_ext_1100_external_auth.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 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
@@ -33,20 +33,13 @@
3333
import os
3434
import subprocess
3535
import tempfile
36-
import unittest
3736

3837
import oracledb
3938
import test_env
4039

4140

42-
@unittest.skipUnless(
43-
test_env.get_extended_config_bool("has_orapki"),
44-
"extended configuration has_orapki is disabled",
45-
)
46-
@unittest.skipIf(
47-
test_env.get_is_thin(),
48-
"thin mode doesn't support external authentication yet",
49-
)
41+
@test_env.skip_unless_thick_mode()
42+
@test_env.skip_unless_has_orapki()
5043
class TestCase(test_env.BaseTestCase):
5144
alias_name = "ext_test_1100"
5245
user = "ext_test_1100_user"

tests/ext/test_ext_1500_pool_grow.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 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
@@ -29,15 +29,11 @@
2929
"""
3030

3131
import time
32-
import unittest
3332

3433
import test_env
3534

3635

37-
@unittest.skipUnless(
38-
test_env.get_extended_config_bool("run_long_tests"),
39-
"extended configuration run_long_tests is disabled",
40-
)
36+
@test_env.skip_unless_run_long_tests()
4137
class TestCase(test_env.BaseTestCase):
4238
def test_ext_1500(self):
4339
"E1500 - test static pool grows back to the min after sessions killed"

tests/ext/test_ext_1900_pool_shrink_async.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,12 @@
2929
"""
3030

3131
import asyncio
32-
import unittest
3332

3433
import test_env
3534

3635

37-
@unittest.skipUnless(
38-
test_env.get_is_thin(), "asyncio not supported in thick mode"
39-
)
40-
@unittest.skipUnless(
41-
test_env.get_extended_config_bool("run_long_tests"),
42-
"extended configuration run_long_tests is disabled",
43-
)
36+
@test_env.skip_unless_thin_mode()
37+
@test_env.skip_unless_run_long_tests()
4438
class TestCase(test_env.BaseAsyncTestCase):
4539
requires_connection = False
4640

tests/ext/test_ext_2000_pool_grow_async.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 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
@@ -36,18 +36,12 @@
3636
# -----------------------------------------------------------------------------
3737

3838
import asyncio
39-
import unittest
4039

4140
import test_env
4241

4342

44-
@unittest.skipUnless(
45-
test_env.get_is_thin(), "asyncio not supported in thick mode"
46-
)
47-
@unittest.skipUnless(
48-
test_env.get_extended_config_bool("run_long_tests"),
49-
"extended configuration run_long_tests is disabled",
50-
)
43+
@test_env.skip_unless_thin_mode()
44+
@test_env.skip_unless_run_long_tests()
5145
class TestCase(test_env.BaseAsyncTestCase):
5246
requires_connection = False
5347

tests/ext/test_ext_2100_bfile_type.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 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
@@ -29,16 +29,12 @@
2929

3030
import os
3131
import tempfile
32-
import unittest
3332

3433
import oracledb
3534
import test_env
3635

3736

38-
@unittest.skipUnless(
39-
test_env.get_extended_config_bool("local_database"),
40-
"extended configuration local_database is disabled",
41-
)
37+
@test_env.skip_unless_local_database()
4238
class TestCase(test_env.BaseTestCase):
4339
dir_name = "EXT_TEST_2100_DIR"
4440

tests/ext/test_ext_2200_bfile_type_async.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 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
@@ -29,19 +29,13 @@
2929

3030
import os
3131
import tempfile
32-
import unittest
3332

3433
import oracledb
3534
import test_env
3635

3736

38-
@unittest.skipUnless(
39-
test_env.get_is_thin(), "asyncio not supported in thick mode"
40-
)
41-
@unittest.skipUnless(
42-
test_env.get_extended_config_bool("local_database"),
43-
"extended configuration local_database is disabled",
44-
)
37+
@test_env.skip_unless_thin_mode()
38+
@test_env.skip_unless_local_database()
4539
class TestCase(test_env.BaseAsyncTestCase):
4640
dir_name = "EXT_TEST_2200_DIR"
4741

tests/ext/test_ext_2500_config_cache.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,12 @@
2929
"""
3030

3131
import time
32-
import unittest
3332

3433
import oracledb
3534
import test_env
3635

3736

38-
@unittest.skipUnless(
39-
test_env.get_extended_config_bool("run_long_tests"),
40-
"extended configuration run_long_tests is disabled",
41-
)
37+
@test_env.skip_unless_run_long_tests()
4238
class TestCase(test_env.BaseTestCase):
4339
def test_ext_2500(self):
4440
"E2500 - test config is cached"

0 commit comments

Comments
 (0)