From df0ee218cc175db8defe6a979ca854c32cc87a42 Mon Sep 17 00:00:00 2001 From: Konstantin Alekseev Date: Wed, 1 Feb 2023 10:57:27 +0200 Subject: [PATCH] Fix pre-commit and apply linters changes --- .github/workflows/tests.yml | 4 +- .pre-commit-config.yaml | 17 +-- README.rst | 4 +- docs/conf.py | 116 +++++++++--------- pytest_splinter/plugin.py | 43 ++++--- pytest_splinter/splinter_patches.py | 4 +- pytest_splinter/webdriver_patches.py | 5 +- setup.py | 21 ++-- tests/conftest.py | 3 +- tests/mocked_browser/conftest.py | 4 +- .../mocked_browser/test_browser_overrides.py | 2 +- tests/mocked_browser/test_screenshot.py | 6 +- tests/test_driverless_browsers.py | 3 +- tests/test_plugin.py | 22 ++-- tests/test_plugin_remote.py | 8 +- 15 files changed, 126 insertions(+), 136 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e393af3..f8bbd5c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: - run: firefox --version - run: geckodriver --version - + - name: Run tests, excluding remote tests run: | xvfb-run -- pytest --junitxml=test-results/junit.xml --ignore=tests/test_plugin_remote.py @@ -44,7 +44,7 @@ jobs: timeout 60 bash -c 'while ! wget -O /dev/null -T 1 http://localhost:4444/readyz; do echo waiting for selenium server; sleep 1; done' || (cat selenium-server.log && exit 2) echo "Selenium server is ready, running tests" pytest --junitxml=test-results/junit.xml tests/test_plugin_remote.py - + - name: Publish Test Report uses: mikepenz/action-junit-report@v3 if: always() # always run even if the previous step fails diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22f676d..f85861b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,4 @@ repos: - - repo: local - hooks: - - id: no_debug - name: Make sure code does not contain commands likely to run interactive debugger - types: [python] - args: [--multiline] - entry: 'breakpoint\(\)|set_trace' - language: pygrep - - repo: https://github.com/myint/autoflake rev: 'v1.4' hooks: @@ -34,7 +25,8 @@ repos: - repo: https://github.com/psf/black rev: '22.3.0' hooks: - - id: black + - id: black + args: ["--skip-string-normalization"] - repo: https://github.com/pre-commit/pre-commit-hooks rev: 'v4.1.0' @@ -44,8 +36,9 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - id: mixed-line-ending + - id: debug-statements - - repo: https://gitlab.com/pycqa/flake8 + - repo: https://github.com/pycqa/flake8 rev: '3.9.2' hooks: - id: flake8 @@ -54,4 +47,4 @@ repos: rev: v2.31.0 hooks: - id: pyupgrade - args: ["--py37-plus"] + args: ["--py36-plus"] diff --git a/README.rst b/README.rst index f864171..b6d8524 100644 --- a/README.rst +++ b/README.rst @@ -133,12 +133,12 @@ Fixtures * splinter_driver_kwargs Webdriver keyword arguments, a dictionary which is passed to selenium webdriver's constructor (after applying firefox preferences) - + .. code-block:: python import pytest from pathlib import Path - + @pytest.fixture def splinter_driver_kwargs(): """ diff --git a/docs/conf.py b/docs/conf.py index 6c6ffd6..380e89e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,4 @@ """Sphinx config.""" -# -*- coding: utf-8 -*- # # pytest-splinter documentation build configuration file, created by # sphinx-quickstart on Sun Apr 7 21:07:56 2013. @@ -16,8 +15,8 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -import sys import os +import sys sys.path.insert(0, os.path.abspath('..')) @@ -26,7 +25,7 @@ # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. @@ -39,15 +38,15 @@ source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. -project = u'pytest-splinter' +project = 'pytest-splinter' AUTHOR = 'Anatoly Bubenkov, Paylogic International and others' -copyright = u'2014, ' + AUTHOR +copyright = '2014, ' + AUTHOR # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -60,37 +59,37 @@ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- @@ -102,26 +101,26 @@ # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -130,44 +129,44 @@ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'pytest-splinter-doc' @@ -177,53 +176,54 @@ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', - + # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', - + # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - #'preamble': '', + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'pytest-splinter.tex', u'pytest-splinter Documentation', AUTHOR, 'manual'), + ( + 'index', + 'pytest-splinter.tex', + 'pytest-splinter Documentation', + AUTHOR, + 'manual', + ), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'pytest-splinter', u'pytest-splinter Documentation', - [AUTHOR], 1) -] +man_pages = [('index', 'pytest-splinter', 'pytest-splinter Documentation', [AUTHOR], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ @@ -232,16 +232,22 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'pytest-splinter', u'pytest-splinter Documentation', - AUTHOR, 'pytest-splinter', 'splinter pytest testing framework integration.', - 'Miscellaneous'), + ( + 'index', + 'pytest-splinter', + 'pytest-splinter Documentation', + AUTHOR, + 'pytest-splinter', + 'splinter pytest testing framework integration.', + 'Miscellaneous', + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' diff --git a/pytest_splinter/plugin.py b/pytest_splinter/plugin.py index 88fd003..167757a 100644 --- a/pytest_splinter/plugin.py +++ b/pytest_splinter/plugin.py @@ -11,6 +11,7 @@ from httplib import HTTPException except ImportError: from http.client import HTTPException + import logging import mimetypes # pragma: no cover import os.path @@ -19,16 +20,13 @@ import pytest # pragma: no cover import splinter # pragma: no cover from _pytest import junitxml - -from urllib3.exceptions import MaxRetryError - -from selenium.webdriver.support import wait -from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.common.exceptions import WebDriverException +from selenium.webdriver.firefox.firefox_profile import FirefoxProfile +from selenium.webdriver.support import wait +from urllib3.exceptions import MaxRetryError -from .webdriver_patches import patch_webdriver # pragma: no cover from .splinter_patches import patch_webdriverelement # pragma: no cover - +from .webdriver_patches import patch_webdriver # pragma: no cover LOGGER = logging.getLogger(__name__) @@ -63,9 +61,9 @@ def _screenshot_extraline(screenshot_png_file_name, screenshot_html_file_name): =========================== pytest-splinter screenshots =========================== -png: %s -html: %s -""" % ( +png: {} +html: {} +""".format( screenshot_png_file_name, screenshot_html_file_name, ) @@ -313,7 +311,7 @@ def get_args( "browser.helperApps.alwaysAsk.force": False, "pdfjs.disabled": True, # disable internal ff pdf viewer to allow auto pdf download }, - **firefox_pref or {} + **firefox_pref or {}, ) if driver == "firefox": @@ -402,7 +400,7 @@ def _take_screenshot( classname = ".".join(names[:-1]) screenshot_dir = os.path.join(splinter_screenshot_dir, classname) screenshot_file_name_format = "{0}.{{format}}".format( - "{}-{}".format(names[-1][: 128 - len(fixture_name) - 5], fixture_name).replace( + f"{names[-1][: 128 - len(fixture_name) - 5]}-{fixture_name}".replace( os.path.sep, "-" ) ) @@ -446,7 +444,7 @@ def _take_screenshot( } ) except Exception as e: # NOQA - warnings.warn(pytest.PytestWarning("Could not save screenshot: {}".format(e))) + warnings.warn(pytest.PytestWarning(f"Could not save screenshot: {e}")) @pytest.yield_fixture(autouse=True) @@ -470,9 +468,8 @@ def _browser_screenshot_session( fixture_values = ( # pytest 3 getattr(request, "_fixture_values", {}) - or # pytest 2 - getattr(request, "_funcargs", {}) + or getattr(request, "_funcargs", {}) ) for name, value in fixture_values.items(): @@ -547,7 +544,7 @@ def get_browser(splinter_webdriver, retry_count=3): visit_condition=splinter_browser_load_condition, visit_condition_timeout=splinter_browser_load_timeout, wait_time=splinter_wait_time, - **kwargs + **kwargs, ) except Exception: # NOQA if retry_count > 1: @@ -591,8 +588,10 @@ def _take_screenshot_on_failure(): try: if splinter_webdriver not in browser.driver_name.lower(): - raise IOError(f"webdriver does not match (requested: {splinter_webdriver} " - f", available: {browser.driver_name.lower()})") + raise OSError( + f"webdriver does not match (requested: {splinter_webdriver} " + f", available: {browser.driver_name.lower()})" + ) if hasattr(browser, "driver"): browser.driver.implicitly_wait(splinter_selenium_implicit_wait) browser.driver.set_speed(splinter_selenium_speed) @@ -608,7 +607,7 @@ def _take_screenshot_on_failure(): browser.driver.set_window_size(*splinter_window_size) try: browser.cookies.delete() - except (IOError, HTTPException, WebDriverException): + except (OSError, HTTPException, WebDriverException): LOGGER.warning("Error cleaning browser cookies", exc_info=True) for url in splinter_clean_cookies_urls: browser.visit(url) @@ -617,7 +616,7 @@ def _take_screenshot_on_failure(): browser.visit_condition = splinter_browser_load_condition browser.visit_condition_timeout = splinter_browser_load_timeout browser.visit("about:blank") - except (IOError, HTTPException, WebDriverException, MaxRetryError): + except (OSError, HTTPException, WebDriverException, MaxRetryError): # we lost browser, try to restore the justice try: browser.quit() @@ -657,7 +656,7 @@ def session_browser(request, browser_instance_getter): return browser_instance_getter(request, session_browser) -class SplinterXdistPlugin(object): +class SplinterXdistPlugin: """Plugin class to defer pytest-xdist hook handler.""" @@ -676,7 +675,7 @@ def pytest_testnodedown(self, node, error): with codecs.open( os.path.join(screenshot_dir, fil["file_name"]), "wb", - **dict(encoding=encoding) if encoding else {} + **dict(encoding=encoding) if encoding else {}, ) as fd: fd.write(fil["content"]) diff --git a/pytest_splinter/splinter_patches.py b/pytest_splinter/splinter_patches.py index 1b5d662..452a768 100644 --- a/pytest_splinter/splinter_patches.py +++ b/pytest_splinter/splinter_patches.py @@ -1,9 +1,7 @@ """Patches for splinter.""" -from functools import partial - -from splinter.driver import webdriver from selenium.webdriver.common.action_chains import ActionChains # pragma: no cover +from splinter.driver import webdriver def patch_webdriverelement(): # pragma: no cover diff --git a/pytest_splinter/webdriver_patches.py b/pytest_splinter/webdriver_patches.py index ae46bd9..b36045c 100644 --- a/pytest_splinter/webdriver_patches.py +++ b/pytest_splinter/webdriver_patches.py @@ -9,9 +9,8 @@ from selenium.webdriver.firefox import webdriver # pragma: no cover from selenium.webdriver.remote.webdriver import ( - WebDriver as RemoteWebDriver, -) # pragma: no cover - + WebDriver as RemoteWebDriver, # pragma: no cover +) # save the original execute RemoteWebDriver._base_execute = RemoteWebDriver.execute # pragma: no cover diff --git a/setup.py b/setup.py index 97d0c9f..99b9ac4 100755 --- a/setup.py +++ b/setup.py @@ -9,9 +9,11 @@ dirname = os.path.dirname(__file__) long_description = ( - codecs.open(os.path.join(dirname, 'README.rst'), encoding='utf-8').read() + '\n' + - codecs.open(os.path.join(dirname, 'AUTHORS.rst'), encoding='utf-8').read() + '\n' + - codecs.open(os.path.join(dirname, 'CHANGES.rst'), encoding='utf-8').read() + codecs.open(os.path.join(dirname, 'README.rst'), encoding='utf-8').read() + + '\n' + + codecs.open(os.path.join(dirname, 'AUTHORS.rst'), encoding='utf-8').read() + + '\n' + + codecs.open(os.path.join(dirname, 'CHANGES.rst'), encoding='utf-8').read() ) setup( @@ -49,13 +51,12 @@ 'Topic :: Utilities', 'Programming Language :: Python :: 3', ] - + [ - ('Programming Language :: Python :: %s' % x) - for x in '3.6 3.7 3.8'.split() - ], + + [('Programming Language :: Python :: %s' % x) for x in '3.6 3.7 3.8'.split()], tests_require=['tox'], - entry_points={'pytest11': [ - 'pytest-splinter=pytest_splinter.plugin', - ]}, + entry_points={ + 'pytest11': [ + 'pytest-splinter=pytest_splinter.plugin', + ] + }, packages=['pytest_splinter'], ) diff --git a/tests/conftest.py b/tests/conftest.py index 7ff6226..527f932 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,6 +4,7 @@ pytest_plugins = "pytester" + @pytest.fixture def simple_page_content(): """Return simple page content.""" @@ -26,5 +27,3 @@ def simple_page(httpserver, browser, simple_page_content): simple_page_content, code=200, headers={"Content-Type": "text/html"} ) browser.visit(httpserver.url) - - diff --git a/tests/mocked_browser/conftest.py b/tests/mocked_browser/conftest.py index 2704629..a7d7316 100644 --- a/tests/mocked_browser/conftest.py +++ b/tests/mocked_browser/conftest.py @@ -1,5 +1,5 @@ """Configuration for pytest runner.""" -import mock +from unittest import mock import pytest @@ -23,7 +23,7 @@ def mocked_browser(driver_name, *args, **kwargs): mocked_browser.driver = mock.MagicMock() mocked_browser.driver.profile = mock.MagicMock() mocked_browser.driver_name = driver_name - mocked_browser.html = u"" + mocked_browser.html = "" def save_screenshot(path): with open(path, "w"): diff --git a/tests/mocked_browser/test_browser_overrides.py b/tests/mocked_browser/test_browser_overrides.py index 74fc1f1..8e0b4f4 100644 --- a/tests/mocked_browser/test_browser_overrides.py +++ b/tests/mocked_browser/test_browser_overrides.py @@ -1,6 +1,6 @@ """Browser overrides tests.""" import time -import mock +from unittest import mock import pytest diff --git a/tests/mocked_browser/test_screenshot.py b/tests/mocked_browser/test_screenshot.py index 9226601..cd0ebd3 100644 --- a/tests/mocked_browser/test_screenshot.py +++ b/tests/mocked_browser/test_screenshot.py @@ -1,7 +1,7 @@ """Browser screenshot tests.""" -import pytest +from unittest import mock -import mock +import pytest def test_browser_screenshot_normal(mocked_browser, testdir): @@ -28,7 +28,7 @@ def test_browser_screenshot_error(mocked_browser, testdir): """Test warning with error during taking screenshots on test failure.""" mocked_browser.return_value.driver.save_screenshot.side_effect = Exception("Failed") mocked_browser.return_value.driver_name = "firefox" - mocked_browser.return_value.html = u"" + mocked_browser.return_value.html = "" testdir.makepyfile( """ diff --git a/tests/test_driverless_browsers.py b/tests/test_driverless_browsers.py index b1b9629..f727d55 100644 --- a/tests/test_driverless_browsers.py +++ b/tests/test_driverless_browsers.py @@ -1,6 +1,7 @@ """Tests for pytest-splinter django driver availability.""" +from unittest import mock + import pytest -import mock @pytest.fixture(autouse=True) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index cb5f862..4ef511b 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -1,11 +1,10 @@ """Tests for pytest-splinter plugin.""" import os.path import time -import socket import pytest - from splinter.driver import DriverAPI + from pytest_splinter.plugin import get_args @@ -25,7 +24,7 @@ def test_status_code(browser, simple_page, splinter_webdriver): "firefox", "zope.testbrowser", ): - skip_msg = "{} doesn't support status code".format(splinter_webdriver) + skip_msg = f"{splinter_webdriver} doesn't support status code" pytest.skip(skip_msg) assert browser.status_code == 200 @@ -43,7 +42,7 @@ def test_status_code_not_implemented(browser, simple_page, splinter_webdriver): not_implemented = True assert not_implemented else: - pytest.skip("{} supports status code".format(splinter_webdriver)) + pytest.skip(f"{splinter_webdriver} supports status code") @pytest.mark.parametrize( @@ -63,15 +62,15 @@ def test_download_file( ): """Test file downloading and accessing it afterwise.""" if splinter_webdriver in ["zope.testbrowser"]: - pytest.skip("{} doesn't support file downloading".format(splinter_webdriver)) + pytest.skip(f"{splinter_webdriver} doesn't support file downloading") if splinter_webdriver in ["firefox"]: pytest.skip("Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1366035") - file_name = "some.{}".format(file_extension) + file_name = f"some.{file_extension}" httpserver.serve_content( "Some text file", code=200, headers={ - "Content-Disposition": "attachment; filename={}".format(file_name), + "Content-Disposition": f"attachment; filename={file_name}", "Content-Type": mime_type, }, ) @@ -80,7 +79,7 @@ def test_download_file( time.sleep(1) file_path = os.path.join(splinter_file_download_dir, file_name) - with open(file_path, "r") as f: + with open(file_path) as f: assert f.read() == "Some text file" @@ -126,7 +125,7 @@ def test_get_text(simple_page, browser, splinter_webdriver): @pytest.mark.parametrize("check", [1, 2]) -@pytest.mark.parametrize("splinter_webdriver", ["firefox", ]) +@pytest.mark.parametrize("splinter_webdriver", ["firefox"]) def test_restore_browser(browser, simple_page, check, splinter_webdriver): """Test that browser is restored after failure automatically.""" if splinter_webdriver == "zope.testbrowser": @@ -134,7 +133,7 @@ def test_restore_browser(browser, simple_page, check, splinter_webdriver): browser.quit() -@pytest.mark.parametrize("splinter_webdriver", ["firefox", ]) +@pytest.mark.parametrize("splinter_webdriver", ["firefox"]) def test_restore_browser_connection( browser, httpserver, simple_page, splinter_webdriver ): @@ -143,7 +142,7 @@ def test_restore_browser_connection( pytest.skip("zope testbrowser doesn't need restore") def raises(*args, **kwargs): - raise socket.error() + raise OSError() browser.driver.command_executor._conn.request = raises browser.reload() @@ -286,4 +285,3 @@ def test_screenshot(simple_page, browser, param): assert testdir.tmpdir.join( "test_browser_screenshot_escaped", "test_screenshot[escaped-param]-browser.png" ) - diff --git a/tests/test_plugin_remote.py b/tests/test_plugin_remote.py index 5a076b6..95a3c7f 100644 --- a/tests/test_plugin_remote.py +++ b/tests/test_plugin_remote.py @@ -1,15 +1,10 @@ """Tests for pytest-splinter plugin.""" -import os.path -import time -import socket import pytest -from splinter.driver import DriverAPI from pytest_splinter.plugin import get_args - @pytest.mark.parametrize("check", [1, 2]) @pytest.mark.parametrize("splinter_webdriver", ["remote"]) def test_restore_browser(browser, simple_page, check, splinter_webdriver): @@ -28,11 +23,12 @@ def test_restore_browser_connection( pytest.skip("zope testbrowser doesn't need restore") def raises(*args, **kwargs): - raise socket.error() + raise OSError() browser.driver.command_executor._conn.request = raises browser.reload() + def test_executable(): """Test argument construction for webdrivers.""" arg1 = get_args(driver="chrome", executable="/tmp")