Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Sep 23, 2024
1 parent 8ef8198 commit 2a63e21
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion py/selenium/webdriver/chromium/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
**kwargs,
) -> None:
self.service_args = service_args or []
driver_path_env_key = driver_path_env_key or 'SE_CHROMEDRIVER'
driver_path_env_key = driver_path_env_key or "SE_CHROMEDRIVER"

if isinstance(log_output, str):
self.service_args.append(f"--log-path={log_output}")
Expand Down
1 change: 1 addition & 0 deletions py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,6 @@ def _start_process(self, path: str) -> None:
f"'{os.path.basename(self._path)}' executable may have wrong permissions."
) from err
raise

def env_path(self) -> Optional[str]:
return os.getenv(self.DRIVER_PATH_ENV_KEY, None)
2 changes: 1 addition & 1 deletion py/selenium/webdriver/edge/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
**kwargs,
) -> None:
self.service_args = service_args or []
driver_path_env_key = driver_path_env_key or 'SE_EDGEDRIVER'
driver_path_env_key = driver_path_env_key or "SE_EDGEDRIVER"

super().__init__(
executable_path=executable_path,
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/ie/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
Default is "stdout".
"""
self.service_args = service_args or []
driver_path_env_key = driver_path_env_key or 'SE_IEDRIVER'
driver_path_env_key = driver_path_env_key or "SE_IEDRIVER"

if host:
self.service_args.append(f"--host={host}")
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/safari/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
**kwargs,
) -> None:
self.service_args = service_args or []
driver_path_env_key = driver_path_env_key or 'SE_SAFARIDRIVER'
driver_path_env_key = driver_path_env_key or "SE_SAFARIDRIVER"

self.reuse_service = reuse_service
super().__init__(
Expand Down
12 changes: 7 additions & 5 deletions py/test/selenium/webdriver/chrome/chrome_service_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,28 @@ def test_log_output_null_default(driver, capfd) -> None:
assert "Starting ChromeDriver" not in out
driver.quit()


@pytest.fixture
def service():
return Service()


@pytest.mark.usefixtures("service")
class TestChromeDriverService:
service_path = "/path/to/chromedriver"

@pytest.fixture(autouse=True)
def setup_and_teardown(self):
os.environ['SE_CHROMEDRIVER'] = self.service_path
os.environ["SE_CHROMEDRIVER"] = self.service_path
yield
os.environ.pop('SE_CHROMEDRIVER', None)
os.environ.pop("SE_CHROMEDRIVER", None)

def test_uses_path_from_env_variable(self, service):
assert 'chromedriver' in service.path
assert "chromedriver" in service.path

def test_updates_path_after_setting_env_variable(self, service):
new_path = "/foo/bar"
os.environ['SE_CHROMEDRIVER'] = new_path
os.environ["SE_CHROMEDRIVER"] = new_path
service.executable_path = self.service_path # Simulating the update

assert 'chromedriver' in service.executable_path
assert "chromedriver" in service.executable_path
12 changes: 7 additions & 5 deletions py/test/selenium/webdriver/firefox/firefox_service_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,28 @@ def test_log_output_as_stdout(capfd) -> None:
assert "geckodriver\tINFO\tListening" in out
driver.quit()


@pytest.fixture
def service():
return Service()


@pytest.mark.usefixtures("service")
class TestGeckoDriverService:
service_path = "/path/to/geckodriver"

@pytest.fixture(autouse=True)
def setup_and_teardown(self):
os.environ['SE_GECKODRIVER'] = self.service_path
os.environ["SE_GECKODRIVER"] = self.service_path
yield
os.environ.pop('SE_GECKODRIVER', None)
os.environ.pop("SE_GECKODRIVER", None)

def test_uses_path_from_env_variable(self, service):
assert 'geckodriver' in service.path
assert "geckodriver" in service.path

def test_updates_path_after_setting_env_variable(self, service):
new_path = "/foo/bar"
os.environ['SE_GECKODRIVER'] = new_path
os.environ["SE_GECKODRIVER"] = new_path
service.executable_path = self.service_path # Simulating the update

assert 'geckodriver' in service.executable_path
assert "geckodriver" in service.executable_path

0 comments on commit 2a63e21

Please sign in to comment.