AppHarness: disable telemetry for test apps (#1733)

This commit is contained in:
Masen Furer 2023-08-31 14:57:28 -07:00 committed by GitHub
parent 63b5fbd7b0
commit ca4724cec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -245,7 +245,11 @@ class Config(Base):
# Convert the env var to the expected type.
try:
env_var = field.type_(env_var)
if issubclass(field.type_, bool):
# special handling for bool values
env_var = env_var.lower() in ["true", "1", "yes"]
else:
env_var = field.type_(env_var)
except ValueError:
console.error(
f"Could not convert {key.upper()}={env_var} to type {field.type_}"

View File

@ -141,6 +141,7 @@ class AppHarness:
)
def _initialize_app(self):
os.environ["TELEMETRY_ENABLED"] = "" # disable telemetry reporting for tests
self.app_path.mkdir(parents=True, exist_ok=True)
if self.app_source is not None:
# get the source from a function or module object

View File

@ -54,6 +54,8 @@ def test_deprecated_params(base_config_values, param):
("DB_URL", "postgresql://user:pass@localhost:5432/db"),
("REDIS_URL", "redis://localhost:6379"),
("TIMEOUT", 600),
("TELEMETRY_ENABLED", False),
("TELEMETRY_ENABLED", True),
],
)
def test_update_from_env(base_config_values, monkeypatch, env_var, value):