Skip to content

Commit 7f5c832

Browse files
committed
[py] Use mock in test_updates_path_after_setting_env_variable
1 parent 416fdfb commit 7f5c832

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/test/selenium/webdriver/safari/safari_service_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import os
1919

20+
from unittest.mock import patch
21+
2022
import pytest
2123

2224
from selenium.webdriver.safari.service import Service
@@ -41,11 +43,9 @@ def test_uses_path_from_env_variable(self, service):
4143
assert "safaridriver" in service.path
4244

4345
def test_updates_path_after_setting_env_variable(self, service):
44-
new_path = "/foo/bar"
45-
os.environ["SE_SAFARIDRIVER"] = new_path
4646
service.executable_path = self.service_path # Simulating the update
47-
48-
assert "safaridriver" in service.executable_path
47+
with patch.dict("os.environ", {"SE_SAFARIDRIVER": "/foo/bar"}):
48+
assert "safaridriver" in service.executable_path
4949

5050

5151
def test_enable_logging():

0 commit comments

Comments
 (0)