Skip to content

Commit f4b82da

Browse files
committed
fix class state leaking across tests for url lib timeouts; add unit test for default
1 parent 409362c commit f4b82da

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

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

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

18-
19-
import urllib3
20-
import pytest
21-
22-
2318
from urllib import parse
2419

20+
import pytest
21+
import urllib3
2522

2623
from selenium import __version__
2724
from selenium.webdriver.remote.remote_connection import (
@@ -96,15 +93,21 @@ def test_get_connection_manager_without_proxy(mock_proxy_settings_missing):
9693
assert type(conn) == urllib3.PoolManager
9794

9895

99-
def test_get_connection_manager_for_certs_and_timeout():
96+
def test_get_connection_manager_for_certs_and_timeout(monkeypatch):
97+
monkeypatch.setattr(RemoteConnection, "get_timeout", lambda _: 10) # Class state; leaks into subsequent tests.
10098
remote_connection = RemoteConnection('http://remote', keep_alive=False)
101-
remote_connection.set_timeout(10)
10299
conn = remote_connection._get_connection_manager()
103100
assert conn.connection_pool_kw['timeout'] == 10
104101
assert conn.connection_pool_kw['cert_reqs'] == 'CERT_REQUIRED'
105102
assert 'certifi/cacert.pem' in conn.connection_pool_kw['ca_certs']
106103

107104

105+
def test_default_socket_timeout_is_correct():
106+
remote_connection = RemoteConnection("http://remote", keep_alive=True)
107+
conn = remote_connection._get_connection_manager()
108+
assert conn.connection_pool_kw['timeout'] is None
109+
110+
108111
def test_get_connection_manager_with_proxy(mock_proxy_settings):
109112
remote_connection = RemoteConnection('http://remote', keep_alive=False)
110113
conn = remote_connection._get_connection_manager()

0 commit comments

Comments
 (0)