90
90
def _initialize ():
91
91
"""
92
92
Performs initialization of the test environment. This ensures the desired
93
- mode is set, imports any required plugins and establishes a test
94
- connection to ensure that the supplied credentials are correct.
93
+ mode is set and imports any required plugins.
95
94
"""
96
- if not get_is_thin ():
95
+ if PARAMETERS .get ("INITIALIZED" ):
96
+ return
97
+ if not get_is_thin () and oracledb .is_thin_mode ():
97
98
oracledb .init_oracle_client ()
98
99
oracledb .defaults .thick_mode_dsn_passthrough = False
99
100
plugin_names = os .environ .get ("PYO_TEST_PLUGINS" )
@@ -102,14 +103,14 @@ def _initialize():
102
103
module_name = f"oracledb.plugins.{ name } "
103
104
print ("importing module" , module_name )
104
105
importlib .import_module (module_name )
106
+ PARAMETERS ["INITIALIZED" ] = True
105
107
106
108
107
109
def get_value (name , label , default_value = None , password = False ):
108
110
try :
109
111
return PARAMETERS [name ]
110
112
except KeyError :
111
113
pass
112
- requires_initialization = len (PARAMETERS ) == 0
113
114
env_name = "PYO_TEST_" + name
114
115
value = os .environ .get (env_name )
115
116
if value is None :
@@ -123,12 +124,11 @@ def get_value(name, label, default_value=None, password=False):
123
124
if not value :
124
125
value = default_value
125
126
PARAMETERS [name ] = value
126
- if requires_initialization :
127
- _initialize ()
128
127
return value
129
128
130
129
131
130
def get_admin_connection (use_async = False ):
131
+ _initialize ()
132
132
admin_user = get_value ("ADMIN_USER" , "Administrative user" , "admin" )
133
133
admin_password = get_value (
134
134
"ADMIN_PASSWORD" , f"Password for { admin_user } " , password = True
@@ -229,6 +229,7 @@ def get_client_version():
229
229
if get_is_thin ():
230
230
value = (23 , 7 )
231
231
else :
232
+ _initialize ()
232
233
value = oracledb .clientversion ()[:2 ]
233
234
PARAMETERS [name ] = value
234
235
return value
@@ -247,6 +248,7 @@ def get_connect_params():
247
248
248
249
249
250
def get_connection (dsn = None , use_async = False , ** kwargs ):
251
+ _initialize ()
250
252
if dsn is None :
251
253
dsn = get_connect_string ()
252
254
method = oracledb .connect_async if use_async else oracledb .connect
@@ -316,6 +318,7 @@ def get_main_user():
316
318
317
319
318
320
def get_pool (use_async = False , ** kwargs ):
321
+ _initialize ()
319
322
method = oracledb .create_pool_async if use_async else oracledb .create_pool
320
323
return method (dsn = get_connect_string (), params = get_pool_params (), ** kwargs )
321
324
0 commit comments