Skip to content

Commit

Permalink
Merge r225447 - WebDriver: auto-install pytest instead of importing i…
Browse files Browse the repository at this point in the history
…t from wpt tools directory

https://bugs.webkit.org/show_bug.cgi?id=180243

Reviewed by Brian Burg.

Tools:

We don't really need the (old) version included in wpt tools dir, so we can simply remove it and use autoinstall
instead.

* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook.find_module): Check pytest.
(AutoinstallImportHook._install_pytest): Install pytest.
* Scripts/webkitpy/webdriver_tests/webdriver_selenium_executor.py: Import autoinstalled pytest.
* Scripts/webkitpy/webdriver_tests/webdriver_test_runner_w3c.py:
(WebDriverTestRunnerW3C.run): Update the subtest path since the new pytest uses a different strategy for
rootdir.
* Scripts/webkitpy/webdriver_tests/webdriver_w3c_executor.py: Import autoinstalled pytest.

WebDriverTests:

* imported/selenium/py/conftest.py: Stop patching this to use yield_fixture, new pytest supports this.
* imported/selenium/py/setup.cfg: Stop patching this, since pytest supports tool:pytest as group name.
* imported/selenium/py/test/selenium/webdriver/common/alerts_tests.py: Stop patching this to use yield_fixture,
new pytest supports this.
* imported/selenium/py/test/selenium/webdriver/common/cookie_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/common/frame_switching_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/common/page_load_timeout_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/common/window_switching_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/safari/conftest.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py: Ditto.
* imported/w3c/importer.json: Stop importing pytest.
* imported/w3c/pytest.ini: Added.
* imported/w3c/tools/pytest/: Removed.
  • Loading branch information
carlosgcampos committed Dec 18, 2017
1 parent 517fc5b commit c6f9488
Show file tree
Hide file tree
Showing 92 changed files with 68 additions and 18,862 deletions.
19 changes: 19 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,22 @@
2017-12-01 Carlos Garcia Campos <cgarcia@igalia.com>

WebDriver: auto-install pytest instead of importing it from wpt tools directory
https://bugs.webkit.org/show_bug.cgi?id=180243

Reviewed by Brian Burg.

We don't really need the (old) version included in wpt tools dir, so we can simply remove it and use autoinstall
instead.

* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook.find_module): Check pytest.
(AutoinstallImportHook._install_pytest): Install pytest.
* Scripts/webkitpy/webdriver_tests/webdriver_selenium_executor.py: Import autoinstalled pytest.
* Scripts/webkitpy/webdriver_tests/webdriver_test_runner_w3c.py:
(WebDriverTestRunnerW3C.run): Update the subtest path since the new pytest uses a different strategy for
rootdir.
* Scripts/webkitpy/webdriver_tests/webdriver_w3c_executor.py: Import autoinstalled pytest.

2017-11-30 Carlos Garcia Campos <cgarcia@igalia.com>

WebDriver: add support for importing and running selenium tests
Expand Down
8 changes: 8 additions & 0 deletions Tools/Scripts/webkitpy/thirdparty/__init__.py
Expand Up @@ -112,6 +112,8 @@ def find_module(self, fullname, _):
self._install_mozprocess()
elif '.pytest_timeout' in fullname:
self._install_pytest_timeout()
elif '.pytest' in fullname:
self._install_pytest()

def _install_mechanize(self):
self._install("https://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz",
Expand Down Expand Up @@ -139,6 +141,12 @@ def _install_pytest_timeout(self):
self._install("https://pypi.python.org/packages/cc/b7/b2a61365ea6b6d2e8881360ae7ed8dad0327ad2df89f2f0be4a02304deb2/pytest-timeout-1.2.0.tar.gz#md5=83607d91aa163562c7ee835da57d061d",
"pytest-timeout-1.2.0/pytest_timeout.py")

def _install_pytest(self):
self._install("https://pypi.python.org/packages/1f/f8/8cd74c16952163ce0db0bd95fdd8810cbf093c08be00e6e665ebf0dc3138/pytest-3.2.5.tar.gz#md5=6dbe9bb093883f75394a689a1426ac6f",
"pytest-3.2.5/_pytest")
self._install("https://pypi.python.org/packages/1f/f8/8cd74c16952163ce0db0bd95fdd8810cbf093c08be00e6e665ebf0dc3138/pytest-3.2.5.tar.gz#md5=6dbe9bb093883f75394a689a1426ac6f",
"pytest-3.2.5/pytest.py")

def _install_pylint(self):
self._ensure_autoinstalled_dir_is_in_sys_path()
if (not self._fs.exists(self._fs.join(_AUTOINSTALLED_DIR, "pylint")) or
Expand Down
Expand Up @@ -27,6 +27,9 @@
from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.webkit_finder import WebKitFinder
import webkitpy.thirdparty.autoinstalled.mozlog
import webkitpy.thirdparty.autoinstalled.pytest
import webkitpy.thirdparty.autoinstalled.pytest_timeout
import pytest

# Since W3C tests also use pytest, we use pytest and some other tools for selenium too.
w3c_tools_dir = WebKitFinder(FileSystem()).path_from_webkit_base('WebDriverTests', 'imported', 'w3c', 'tools')
Expand All @@ -35,11 +38,8 @@
def _ensure_directory_in_path(directory):
if not directory in sys.path:
sys.path.insert(0, directory)
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'pytest'))
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'wptrunner'))

import pytest
import webkitpy.thirdparty.autoinstalled.pytest_timeout
from wptrunner.executors.pytestrunner.runner import HarnessResultRecorder, SubtestResultRecorder, TemporaryDirectory

_log = logging.getLogger(__name__)
Expand Down
Expand Up @@ -94,8 +94,8 @@ def run(self, tests=[]):
harness_result, test_results = executor.run(test)
result = WebDriverTestResult(test_name, *harness_result)
if harness_result[0] == 'OK':
for test_result in test_results:
result.add_subtest_results(*test_result)
for subtest, status, message, backtrace in test_results:
result.add_subtest_results(os.path.basename(subtest), status, message, backtrace)
else:
# FIXME: handle other results.
pass
Expand Down
Expand Up @@ -28,6 +28,8 @@
from webkitpy.common.webkit_finder import WebKitFinder
import webkitpy.thirdparty.autoinstalled.mozlog
import webkitpy.thirdparty.autoinstalled.mozprocess
import webkitpy.thirdparty.autoinstalled.pytest
import webkitpy.thirdparty.autoinstalled.pytest_timeout
from mozlog import structuredlog

w3c_tools_dir = WebKitFinder(FileSystem()).path_from_webkit_base('WebDriverTests', 'imported', 'w3c', 'tools')
Expand All @@ -36,11 +38,9 @@
def _ensure_directory_in_path(directory):
if not directory in sys.path:
sys.path.insert(0, directory)
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'pytest'))
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'webdriver'))
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'wptrunner'))

import webkitpy.thirdparty.autoinstalled.pytest_timeout
from wptrunner.executors.base import WdspecExecutor, WebDriverProtocol
from wptrunner.webdriver_server import WebDriverServer

Expand Down
21 changes: 21 additions & 0 deletions WebDriverTests/ChangeLog
@@ -1,3 +1,24 @@
2017-12-01 Carlos Garcia Campos <cgarcia@igalia.com>

WebDriver: auto-install pytest instead of importing it from wpt tools directory
https://bugs.webkit.org/show_bug.cgi?id=180243

Reviewed by Brian Burg.

* imported/selenium/py/conftest.py: Stop patching this to use yield_fixture, new pytest supports this.
* imported/selenium/py/setup.cfg: Stop patching this, since pytest supports tool:pytest as group name.
* imported/selenium/py/test/selenium/webdriver/common/alerts_tests.py: Stop patching this to use yield_fixture,
new pytest supports this.
* imported/selenium/py/test/selenium/webdriver/common/cookie_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/common/frame_switching_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/common/page_load_timeout_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/common/window_switching_tests.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/safari/conftest.py: Ditto.
* imported/selenium/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py: Ditto.
* imported/w3c/importer.json: Stop importing pytest.
* imported/w3c/pytest.ini: Added.
* imported/w3c/tools/pytest/: Removed.

2017-11-30 Carlos Garcia Campos <cgarcia@igalia.com>

WebDriver: add support for importing and running selenium tests
Expand Down
6 changes: 3 additions & 3 deletions WebDriverTests/imported/selenium/py/conftest.py
Expand Up @@ -67,7 +67,7 @@ def pytest_ignore_collect(path, config):
driver_instance = None


@pytest.yield_fixture(scope='function')
@pytest.fixture(scope='function')
def driver(request):
kwargs = {}

Expand Down Expand Up @@ -157,7 +157,7 @@ def load(self, name):
return Pages()


@pytest.yield_fixture(autouse=True, scope='session')
@pytest.fixture(autouse=True, scope='session')
def server(request):
drivers = request.config.getoption('drivers')
if drivers is None or 'Remote' not in drivers:
Expand Down Expand Up @@ -196,7 +196,7 @@ def wait_for_server(url, timeout):
print('Selenium server has been terminated')


@pytest.yield_fixture(autouse=True, scope='session')
@pytest.fixture(autouse=True, scope='session')
def webserver():
webserver = SimpleWebServer(host=get_lan_ip())
webserver.start()
Expand Down
2 changes: 1 addition & 1 deletion WebDriverTests/imported/selenium/py/setup.cfg
Expand Up @@ -5,7 +5,7 @@ universal = 1
exclude = .tox,docs/source/conf.py
ignore = E501

[pytest]
[tool:pytest]
addopts = -r=a
python_files = test_*.py *_tests.py
testpaths = test
Expand Up @@ -29,7 +29,7 @@
WebDriverException)


@pytest.yield_fixture(autouse=True)
@pytest.fixture(autouse=True)
def close_alert(driver):
yield
try:
Expand Down
Expand Up @@ -33,7 +33,7 @@ def cookie(webserver):
return cookie


@pytest.yield_fixture(autouse=True)
@pytest.fixture(autouse=True)
def pages(request, driver, pages):
pages.load('simpleTest.html')
yield pages
Expand Down
Expand Up @@ -38,7 +38,7 @@
# ----------------------------------------------------------------------------------------------


@pytest.yield_fixture(autouse=True)
@pytest.fixture(autouse=True)
def restore_default_context(driver):
yield
driver.switch_to.default_content()
Expand Down
Expand Up @@ -20,7 +20,7 @@
from selenium.common.exceptions import TimeoutException


@pytest.yield_fixture(autouse=True)
@pytest.fixture(autouse=True)
def reset_timeouts(driver):
yield
driver.set_page_load_timeout(300)
Expand Down
Expand Up @@ -24,7 +24,7 @@
from selenium.webdriver.support.ui import WebDriverWait


@pytest.yield_fixture(autouse=True)
@pytest.fixture(autouse=True)
def close_windows(driver):
main_windows_handle = driver.current_window_handle
yield
Expand Down
Expand Up @@ -30,7 +30,7 @@ def driver_kwargs():
return {}


@pytest.yield_fixture
@pytest.fixture
def driver(driver_class, driver_kwargs):
driver = driver_class(**driver_kwargs)
yield driver
Expand Down
Expand Up @@ -28,7 +28,7 @@
from selenium.webdriver.support.ui import WebDriverWait


@pytest.yield_fixture
@pytest.fixture
def log():
log = BytesIO()
yield log
Expand Down
1 change: 0 additions & 1 deletion WebDriverTests/imported/w3c/importer.json
Expand Up @@ -2,7 +2,6 @@
"repository": "https://github.com/w3c/web-platform-tests.git",
"revision": "2b50389ee72d89dd0be12bc6ca54a6e95c98d163",
"paths_to_import": [
"tools/pytest",
"tools/webdriver",
"tools/wptrunner",
"webdriver"
Expand Down
2 changes: 2 additions & 0 deletions WebDriverTests/imported/w3c/pytest.ini
@@ -0,0 +1,2 @@
# Pytest config file. We don't have any special configuration for pytest,
# but the existance of this file here determines the rootdir used by pytest.
7 changes: 0 additions & 7 deletions WebDriverTests/imported/w3c/tools/pytest/.coveragerc

This file was deleted.

1 change: 0 additions & 1 deletion WebDriverTests/imported/w3c/tools/pytest/.gitattributes

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions WebDriverTests/imported/w3c/tools/pytest/.gitignore

This file was deleted.

40 changes: 0 additions & 40 deletions WebDriverTests/imported/w3c/tools/pytest/.travis.yml

This file was deleted.

0 comments on commit c6f9488

Please sign in to comment.