diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 9cba9c3eb..0d77e4614 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -7,7 +7,7 @@ import sys sys.path.insert( 0, str((Path(__file__).resolve().parents[1] / 'test'))) -import conftest # noqa +import conftest # noqa: E402 SKIP = set(['fft', 'hyantes', 'README']) diff --git a/pyodide_build/_fixes.py b/pyodide_build/_fixes.py new file mode 100644 index 000000000..a9f79bc4f --- /dev/null +++ b/pyodide_build/_fixes.py @@ -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 diff --git a/test/conftest.py b/test/conftest.py index 877b501f2..230b96696 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -16,6 +16,15 @@ import shutil TEST_PATH = pathlib.Path(__file__).parents[0].resolve() 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: import pytest