from ...testing.provision import set_default_schema_on_connection
from ...testing.provision import stop_test_class_outside_fixtures
from ...testing.provision import temp_table_keyword_args
+from ...testing.provision import update_db_opts
@create_db.for_db("oracle")
cursor = dbapi_connection.cursor()
cursor.execute("ALTER SESSION SET CURRENT_SCHEMA=%s" % schema_name)
cursor.close()
+
+
+@update_db_opts.for_db("oracle")
+def _update_db_opts(db_url, db_opts, options):
+ """Set database options (db_opts) for a test database that we created."""
+ if (
+ options.oracledb_thick_mode
+ and sa_url.make_url(db_url).get_driver_name() == "oracledb"
+ ):
+ db_opts["thick_mode"] = True
dest="profiledump",
help="Filename where a single profile run will be dumped",
)
- make_option(
- "--postgresql-templatedb",
- type=str,
- help="name of template database to use for PostgreSQL "
- "CREATE DATABASE (defaults to current database)",
- )
make_option(
"--low-connections",
action="store_true",
help="Additional test directories to add to the mypy tests. "
"This is used only when running mypy tests. Multiple OK",
)
+ # db specific options
+ make_option(
+ "--postgresql-templatedb",
+ type=str,
+ help="name of template database to use for PostgreSQL "
+ "CREATE DATABASE (defaults to current database)",
+ )
+ make_option(
+ "--oracledb-thick-mode",
+ action="store_true",
+ help="enables the 'thick mode' when testing with oracle+oracledb",
+ )
def configure_follower(follower_ident):
class register:
- def __init__(self):
+ def __init__(self, decorator=None):
self.fns = {}
+ self.decorator = decorator
@classmethod
def init(cls, fn):
return register().for_db("*")(fn)
+ @classmethod
+ def init_decorator(cls, decorator):
+ return register(decorator).for_db("*")
+
def for_db(self, *dbnames):
def decorate(fn):
+ if self.decorator:
+ fn = self.decorator(fn)
for dbname in dbnames:
self.fns[dbname] = fn
return self
if follower_ident:
db_url = follower_url_from_main(db_url, follower_ident)
db_opts = {}
- update_db_opts(db_url, db_opts)
+ update_db_opts(db_url, db_opts, options)
db_opts["scope"] = "global"
eng = engines.testing_engine(db_url, db_opts)
post_configure_engine(db_url, eng, follower_ident)
raise NotImplementedError("no DB drop routine for cfg: %s" % (eng.url,))
-@register.init
-def update_db_opts(db_url, db_opts):
+def _adapt_update_db_opts(fn):
+ insp = util.inspect_getfullargspec(fn)
+ if len(insp.args) == 3:
+ return fn
+ else:
+ return lambda db_url, db_opts, _options: fn(db_url, db_opts)
+
+
+@register.init_decorator(_adapt_update_db_opts)
+def update_db_opts(db_url, db_opts, options):
"""Set database options (db_opts) for a test database that we created."""
- pass
@register.init
(For the internal dialects, currently only used by sqlite, oracle)
"""
- pass
@register.init
use. For the internal dialects, this is currently only necessary for
mssql and oracle.
"""
- pass
def reap_dbs(idents_file):