From a8d5cb89a8f35e01a8e420c89bc19a9f8b61aa45 Mon Sep 17 00:00:00 2001 From: Elizabeth Thompson Date: Fri, 10 Mar 2023 16:07:50 -0800 Subject: [PATCH] chore: use util test env for init check (#23325) --- .github/workflows/superset-python-unittest.yml | 2 ++ superset/initialization/__init__.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/superset-python-unittest.yml b/.github/workflows/superset-python-unittest.yml index 1ff07375d4727..8c94d0f4582cd 100644 --- a/.github/workflows/superset-python-unittest.yml +++ b/.github/workflows/superset-python-unittest.yml @@ -50,6 +50,8 @@ jobs: mkdir ${{ github.workspace }}/.temp - name: Python unit tests if: steps.check.outcome == 'failure' + env: + SUPERSET_TESTENV: true run: | pytest --durations-min=0.5 --cov-report= --cov=superset ./tests/common ./tests/unit_tests --cache-clear - name: Upload code coverage diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index 8d5508fb8dd75..b911461e9c865 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -53,7 +53,7 @@ from superset.security import SupersetSecurityManager from superset.superset_typing import FlaskResponse from superset.tags.core import register_sqla_event_listeners -from superset.utils.core import pessimistic_connection_handling +from superset.utils.core import is_test, pessimistic_connection_handling from superset.utils.log import DBEventLogger, get_event_logger_from_cfg_value if TYPE_CHECKING: @@ -476,8 +476,7 @@ def log_default_secret_key_warning() -> None: if ( self.superset_app.debug or self.superset_app.config["TESTING"] - # There must be a better way - or "pytest" in sys.modules + or is_test() ): logger.warning("Debug mode identified with default secret key") log_default_secret_key_warning()