potiuk commented on code in PR #28631:
URL: https://github.com/apache/airflow/pull/28631#discussion_r1059077247
##########
tests/conftest.py:
##########
@@ -856,3 +851,24 @@ def reset_logging_config():
logging_config = import_string(settings.LOGGING_CLASS_PATH)
logging.config.dictConfig(logging_config)
+
+
[email protected](scope="module", autouse=True)
+def _clear_db(request):
+ """Clear DB before each test module run."""
+ if not request.config.option.db_cleanup:
+ return
+ dist_option = getattr(request.config.option, "dist", "no")
+ if dist_option != "no" or hasattr(request.config, "workerinput"):
+ # Skip if pytest-xdist detected (controller or worker)
+ return
+
+ try:
+ clear_all()
+ except Exception as ex:
+ exc_name_parts = [type(ex).__name__]
+ exc_module = type(ex).__module__
+ if exc_module != "builtins":
+ exc_name_parts.insert(0, exc_module)
+ extra_msg = "" if request.config.option.db_init else ", try to run
with flag --with-db-init"
Review Comment:
I like the escalation here and informative message.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]