From c158a799eae8d1838abfed08532d7fef6612564c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 30 Oct 2023 16:25:44 +0100 Subject: [PATCH] [py] Fix test for CONDA_PREFIX in selenium_manager Accessing CONDA_PREFIX in os.environ fails with a KeyError when it is not set. The condition should instead check for the existence of the key, before accessing it in the following codepath Fixes: d4285d1 ("fix for conda install of selenium-manager (#12536)") --- py/selenium/webdriver/common/selenium_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index fa26f73b9f9c0..d12a1d35b14f7 100644 --- a/py/selenium/webdriver/common/selenium_manager.py +++ b/py/selenium/webdriver/common/selenium_manager.py @@ -57,7 +57,7 @@ def get_binary() -> Path: path = Path(__file__).parent.joinpath(directory, file) - if not path.is_file() and os.environ["CONDA_PREFIX"]: + if not path.is_file() and "CONDA_PREFIX" in os.environ: # conda has a separate package selenium-manager, installs in bin path = Path(os.path.join(os.environ["CONDA_PREFIX"], "bin", file)) logger.debug("Conda environment detected, using `%s`", path)