Skip to content

Commit fc40c52

Browse files
Make it easier to use Instant Client for Mac & Windows testing.
1 parent cb464ab commit fc40c52

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/test_env.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@
4343
# PYO_TEST_EXTERNAL_USER: user for testing external authentication
4444
# PYO_TEST_EDITION_NAME: name of edition for editioning tests
4545
# PYO_TEST_PLUGINS: list of plugins to import before running tests
46+
# PYO_TEST_ORACLE_CLIENT_PATH: Oracle Client or Instant Client library dir
4647
#
4748
# PYO_TEST_CONNECT_STRING can be set to an Easy Connect string, or a
4849
# Net Service Name from a tnsnames.ora file or external naming service,
4950
# or it can be the name of a local Oracle database instance.
5051
#
52+
# On Windows set PYO_TEST_ORACLE_CLIENT_PATH if Oracle libraries are not in
53+
# PATH. On macOS set the variable to the Instant Client directory. On Linux do
54+
# not set the variable; instead set LD_LIBRARY_PATH or configure ldconfig
55+
# before running Python.
56+
#
5157
# If oracledb is using Instant Client, then an Easy Connect string is generally
5258
# appropriate. The syntax is:
5359
#
@@ -68,6 +74,7 @@
6874
import getpass
6975
import importlib
7076
import os
77+
import platform
7178
import secrets
7279
import sys
7380
import string
@@ -95,7 +102,7 @@ def _initialize():
95102
if PARAMETERS.get("INITIALIZED"):
96103
return
97104
if not get_is_thin() and oracledb.is_thin_mode():
98-
oracledb.init_oracle_client()
105+
oracledb.init_oracle_client(lib_dir=get_oracle_client())
99106
oracledb.defaults.thick_mode_dsn_passthrough = False
100107
plugin_names = os.environ.get("PYO_TEST_PLUGINS")
101108
if plugin_names is not None:
@@ -232,6 +239,11 @@ def get_client_version():
232239
return value
233240

234241

242+
def get_oracle_client():
243+
if platform.system() == "Darwin" or platform.system() == "Windows":
244+
return get_value("ORACLE_CLIENT_PATH", "Oracle Instant Client Path")
245+
246+
235247
def get_connect_params():
236248
wallet_location = get_wallet_location()
237249
return oracledb.ConnectParams(
@@ -487,6 +499,8 @@ def skip_soda_tests():
487499
return True
488500
if has_server_version(20, 1) and not has_client_version(20, 1):
489501
return True
502+
if has_client_version(23, 3) and platform.system() == "Darwin":
503+
return True
490504
return False
491505

492506

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ passenv =
1616
PYO_TEST_WALLET_PASSWORD
1717
PYO_TEST_EXTERNAL_USER
1818
PYO_TEST_EDITION_NAME
19+
PYO_TEST_ORACLE_CLIENT_PATH
1920
DPI_DEBUG_LEVEL
2021
ORACLE_HOME
2122

0 commit comments

Comments
 (0)