Skip to content

Commit f6f0098

Browse files
committed
[py] Use mocks in tests
1 parent 7f5c832 commit f6f0098

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

py/test/selenium/webdriver/chrome/chrome_service_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
import subprocess
1919
import time
20-
2120
from unittest.mock import patch
2221

2322
import pytest

py/test/selenium/webdriver/chrome/proxy_tests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import os
19-
2018
from unittest.mock import patch
2119

2220
import pytest

py/test/selenium/webdriver/edge/edge_service_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
import subprocess
1919
import time
20-
2120
from unittest.mock import patch
2221

2322
import pytest

py/test/selenium/webdriver/firefox/firefox_service_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717
import os
1818
import subprocess
19-
2019
from unittest.mock import patch
2120

2221
import pytest

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717

1818
import os
19-
2019
from unittest.mock import patch
2120

2221
import pytest

py/test/unit/selenium/webdriver/remote/remote_connection_tests.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import os
1918
from unittest.mock import patch
2019
from urllib import parse
2120

@@ -168,18 +167,17 @@ def test_get_proxy_direct_via_client_config():
168167

169168

170169
def test_get_proxy_system_matches_no_proxy_via_client_config():
171-
os.environ["HTTP_PROXY"] = "http://admin:admin@system_proxy.com:8080"
172-
os.environ["NO_PROXY"] = "localhost,127.0.0.1"
173-
client_config = ClientConfig(
174-
remote_server_addr="http://localhost:4444", proxy=Proxy({"proxyType": ProxyType.SYSTEM})
175-
)
176-
remote_connection = RemoteConnection(client_config=client_config)
177-
conn = remote_connection._get_connection_manager()
178-
assert isinstance(conn, urllib3.PoolManager)
179-
proxy_url = remote_connection._client_config.get_proxy_url()
180-
assert proxy_url is None
181-
os.environ.pop("HTTP_PROXY")
182-
os.environ.pop("NO_PROXY")
170+
with patch.dict(
171+
"os.environ", {"HTTP_PROXY": "http://admin:admin@system_proxy.com:8080", "NO_PROXY": "localhost,127.0.0.1"}
172+
):
173+
client_config = ClientConfig(
174+
remote_server_addr="http://localhost:4444", proxy=Proxy({"proxyType": ProxyType.SYSTEM})
175+
)
176+
remote_connection = RemoteConnection(client_config=client_config)
177+
conn = remote_connection._get_connection_manager()
178+
assert isinstance(conn, urllib3.PoolManager)
179+
proxy_url = remote_connection._client_config.get_proxy_url()
180+
assert proxy_url is None
183181

184182

185183
def test_get_proxy_url_none(mock_proxy_settings_missing):

0 commit comments

Comments
 (0)