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 <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-05-18 02:46:56 -07:00
parent 3f1f03e03c
commit 66189c4460
2 changed files with 11 additions and 9 deletions

View file

@ -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))

View file

@ -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()