From 4adffc4ce4ef37bf0db0650bdc521511ac816312 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 9 Dec 2022 13:00:38 -0300 Subject: [PATCH] Use Firefox as webdriver for tests --- environment.devenv.yml | 7 ++++--- scripts/run_tests.sh | 1 - tests/conftest.py | 34 +++------------------------------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/environment.devenv.yml b/environment.devenv.yml index 5d3cf52..89985d7 100644 --- a/environment.devenv.yml +++ b/environment.devenv.yml @@ -9,7 +9,7 @@ includes: environment: # Tip: Use `--driver ` to change driver for a single run {% if TEST_QMXGRAPH %} - PYTEST_ADDOPTS: --driver PhantomJS + PYTEST_ADDOPTS: --driver Firefox {% endif %} dependencies: @@ -18,11 +18,12 @@ dependencies: {% if TEST_QMXGRAPH %} - cherrypy - hypothesis =3.11 - - phantomjs + - firefox + - geckodriver - pytest-mock - pytest-qt - pytest-rerunfailures - - pytest-selenium >=1,<2 + - pytest-selenium - pytest-timeout - typing-extensions <4.2.0 # [PYTHON_VERSION=="3.6"] # Pin importlib_resources due to #151. diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 7ec1393..9585a0d 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -1,6 +1,5 @@ #!/bin/bash git clone --depth=1 --branch v3.7.5 https://github.com/jgraph/mxgraph.git -export PYTEST_ADDOPTS="--driver PhantomJS" export MXGRAPHPATH=mxgraph inv qrc inv test diff --git a/tests/conftest.py b/tests/conftest.py index 0608218..bfe24cf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,4 @@ import os -import shutil import pytest @@ -10,43 +9,16 @@ def pytest_configure(config): # of pytest so they can't reliably be removed by a fixture. config.cache.set('qmxgraph/ports', []) - # Ensure phantomjs is available. - phantomjs = shutil.which("phantomjs") - assert phantomjs is not None - lock_file = _get_port_lock_filename(config.rootdir) if os.path.isfile(lock_file): os.remove(lock_file) # Fixtures -------------------------------------------------------------------- - - -@pytest.fixture -def phantomjs_driver(capabilities, driver_path, port): - """ - Overrides default `phantomjs_driver` driver from pytest-selenium. - - Default implementation uses ephemeral ports just as our tests but - it doesn't provide any way to configure them, for this reason we basically - recreate the driver fixture using port fixture. - """ - kwargs = {} - if capabilities: - kwargs['desired_capabilities'] = capabilities - if driver_path is not None: - kwargs['executable_path'] = driver_path - - kwargs['port'] = port.get() - - from selenium.webdriver import PhantomJS - - return PhantomJS(**kwargs) - - @pytest.fixture -def driver_args(): - return ['--debug=true'] +def firefox_options(firefox_options): + firefox_options.headless = True + return firefox_options @pytest.fixture(autouse=True)