Merge pull request #210 from rth/fix-selenium

Hotfix selenium ConnectionError issue
This commit is contained in:
Michael Droettboom 2018-10-05 12:14:04 -04:00 committed by GitHub
commit 4abf42d0bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import sys
sys.path.insert( sys.path.insert(
0, str((Path(__file__).resolve().parents[1] / 'test'))) 0, str((Path(__file__).resolve().parents[1] / 'test')))
import conftest # noqa import conftest # noqa: E402
SKIP = set(['fft', 'hyantes', 'README']) SKIP = set(['fft', 'hyantes', 'README'])

22
pyodide_build/_fixes.py Normal file
View File

@ -0,0 +1,22 @@
import socket
# Temporary fix from https://github.com/SeleniumHQ/selenium/pull/6480
# to avoid ConnectionError in selenium
def _selenium_is_connectable(port, host="localhost"):
"""
Tries to connect to the server at port to see if it is running.
:Args:
- port - The port to connect.
"""
socket_ = None
try:
socket_ = socket.create_connection((host, port), 1)
result = True
except (socket.error, ConnectionError):
result = False
finally:
if socket_:
socket_.close()
return result

View File

@ -16,6 +16,15 @@ import shutil
TEST_PATH = pathlib.Path(__file__).parents[0].resolve() TEST_PATH = pathlib.Path(__file__).parents[0].resolve()
BUILD_PATH = TEST_PATH / '..' / 'build' BUILD_PATH = TEST_PATH / '..' / 'build'
sys.path.append(TEST_PATH / '..')
from pyodide_build._fixes import _selenium_is_connectable # noqa: E402
import selenium.webdriver.common.utils # noqa: E402
# XXX: Temporary fix for ConnectionError in selenium
selenium.webdriver.common.utils.is_connectable = _selenium_is_connectable
try: try:
import pytest import pytest