Commit 66189c44 authored by Kevin Morris's avatar Kevin Morris
Browse files

alembic: restore logging, fix pytest conflicts



In this case, when running pytests, we do not allow alembic to
configure loggers.

Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 3f1f03e0
......@@ -40,6 +40,7 @@ def run(args):
if args.use_alembic:
alembic_config = alembic.config.Config('alembic.ini')
alembic_config.get_main_option('script_location')
alembic_config.attributes["configure_logger"] = False
engine = sqlalchemy.create_engine(aurweb.db.get_sqlalchemy_url(),
echo=(args.verbose >= 1))
......
......@@ -20,6 +20,12 @@ target_metadata = aurweb.schema.metadata
# ... etc.
# If configure_logger is either True or not specified,
# configure the logger via fileConfig.
if config.attributes.get("configure_logger", True):
logging.config.fileConfig(config.config_file_name)
def run_migrations_offline():
"""Run migrations in 'offline' mode.
......@@ -64,12 +70,7 @@ def run_migrations_online():
context.run_migrations()
if __name__ == "__main__":
# Interpret the config file for Python logging.
# This line sets up loggers basically.
logging.config.fileConfig(config.config_file_name)
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment