mirror of
https://github.com/apache/superset.git
synced 2026-04-07 10:31:50 +00:00
fix: do not import superset_config on tests (#11193)
* Do not import superset_config on tests * Use strtobool
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
set -e
|
||||
|
||||
export SUPERSET_CONFIG=${SUPERSET_CONFIG:-tests.superset_test_config}
|
||||
export SUPERSET_TESTENV=true
|
||||
echo "Superset config module: $SUPERSET_CONFIG"
|
||||
|
||||
superset db upgrade
|
||||
|
||||
@@ -42,6 +42,7 @@ from superset.jinja_context import ( # pylint: disable=unused-import
|
||||
)
|
||||
from superset.stats_logger import DummyStatsLogger
|
||||
from superset.typing import CacheConfig
|
||||
from superset.utils.core import is_test
|
||||
from superset.utils.log import DBEventLogger
|
||||
from superset.utils.logging_configurator import DefaultLoggingConfigurator
|
||||
|
||||
@@ -952,7 +953,7 @@ if CONFIG_PATH_ENV_VAR in os.environ:
|
||||
"Failed to import config for %s=%s", CONFIG_PATH_ENV_VAR, cfg_path
|
||||
)
|
||||
raise
|
||||
elif importlib.util.find_spec("superset_config"):
|
||||
elif importlib.util.find_spec("superset_config") and not is_test():
|
||||
try:
|
||||
import superset_config # pylint: disable=import-error
|
||||
from superset_config import * # type: ignore # pylint: disable=import-error,wildcard-import,unused-wildcard-import
|
||||
|
||||
@@ -31,6 +31,7 @@ import traceback
|
||||
import uuid
|
||||
import zlib
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from distutils.util import strtobool
|
||||
from email.mime.application import MIMEApplication
|
||||
from email.mime.image import MIMEImage
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
@@ -1564,3 +1565,7 @@ class AdhocMetricExpressionType(str, Enum):
|
||||
class RowLevelSecurityFilterType(str, Enum):
|
||||
REGULAR = "Regular"
|
||||
BASE = "Base"
|
||||
|
||||
|
||||
def is_test() -> bool:
|
||||
return strtobool(os.environ.get("SUPERSET_TESTENV", "false"))
|
||||
|
||||
1
tox.ini
1
tox.ini
@@ -28,6 +28,7 @@ deps =
|
||||
-rrequirements/testing.txt
|
||||
setenv =
|
||||
PYTHONPATH = {toxinidir}
|
||||
SUPERSET_TESTENV = true
|
||||
SUPERSET_CONFIG = tests.superset_test_config
|
||||
SUPERSET_HOME = {envtmpdir}
|
||||
mysql: SUPERSET__SQLALCHEMY_DATABASE_URI = mysql://mysqluser:mysqluserpassword@localhost/superset?charset=utf8
|
||||
|
||||
Reference in New Issue
Block a user