1
0
Эх сурвалжийг харах

AppHarness: disable telemetry for test apps (#1733)

Masen Furer 1 жил өмнө
parent
commit
ca4724cec8

+ 5 - 1
reflex/config.py

@@ -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_}"

+ 1 - 0
reflex/testing.py

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

+ 2 - 0
tests/test_config.py

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