mirror of https://github.com/pyodide/pyodide.git
Merge pull request #210 from rth/fix-selenium
Hotfix selenium ConnectionError issue
This commit is contained in:
commit
4abf42d0bc
|
@ -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'])
|
||||||
|
|
|
@ -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
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue