migrate APP_HARNESS_HEADLESS to new env var system

This commit is contained in:
Benedikt Bartscher 2024-10-28 22:55:15 +01:00
parent 84057093ac
commit f16273fa11
No known key found for this signature in database
3 changed files with 6 additions and 2 deletions

View File

@ -491,6 +491,9 @@ class EnvironmentVariables:
# If this env var is set to "yes", App.compile will be a no-op # If this env var is set to "yes", App.compile will be a no-op
REFLEX_SKIP_COMPILE: EnvVar[bool] = env_var(False, internal=True) REFLEX_SKIP_COMPILE: EnvVar[bool] = env_var(False, internal=True)
# Whether to run app harness tests in headless mode.
APP_HARNESS_HEADLESS: EnvVar[bool] = env_var(False)
environment = EnvironmentVariables() environment = EnvironmentVariables()

View File

@ -617,7 +617,7 @@ class AppHarness:
if self.frontend_url is None: if self.frontend_url is None:
raise RuntimeError("Frontend is not running.") raise RuntimeError("Frontend is not running.")
want_headless = False want_headless = False
if os.environ.get("APP_HARNESS_HEADLESS"): if environment.APP_HARNESS_HEADLESS.get:
want_headless = True want_headless = True
if driver_clz is None: if driver_clz is None:
requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome") requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome")

View File

@ -6,6 +6,7 @@ from pathlib import Path
import pytest import pytest
from reflex.config import environment
from reflex.testing import AppHarness, AppHarnessProd from reflex.testing import AppHarness, AppHarnessProd
DISPLAY = None DISPLAY = None
@ -21,7 +22,7 @@ def xvfb():
Yields: Yields:
the pyvirtualdisplay object that the browser will be open on the pyvirtualdisplay object that the browser will be open on
""" """
if os.environ.get("GITHUB_ACTIONS") and not os.environ.get("APP_HARNESS_HEADLESS"): if os.environ.get("GITHUB_ACTIONS") and not environment.APP_HARNESS_HEADLESS.get:
from pyvirtualdisplay.smartdisplay import ( # pyright: ignore [reportMissingImports] from pyvirtualdisplay.smartdisplay import ( # pyright: ignore [reportMissingImports]
SmartDisplay, SmartDisplay,
) )