Skip to content

Commit

Permalink
Update patch_webdriver
Browse files Browse the repository at this point in the history
Allow passing args to pytest

Add MaxRetryError to caught exceptions

Add urllib3 to install requirements
  • Loading branch information
jsfehler committed Aug 30, 2018
1 parent 486dcba commit ffd0f5c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions CHANGES.rst
Expand Up @@ -4,13 +4,13 @@ Changelog
1.9.2
-----

- Bump minimum splinter version to 0.9.0
- Remove phantomjs support.
- Bump minimum splinter version to 0.9.0 (jsfehler)
- Remove phantomjs support. (jsfehler)

1.9.1
-----

- Fix utf-8 decode warnings when taking screenshots with pytest-xdist active `#108 <https://github.com/pytest-dev/pytest-splinter/issues/108>`_ (jsfehler)
- Fix utf-8 decode warnings when taking screenshots with pytest-xdist active `#108 <https://github.com/pytest-dev/pytest-splinter/issues/108>`_ (jsfehler)


1.9.0
Expand Down
2 changes: 1 addition & 1 deletion pytest_splinter/__init__.py
@@ -1,2 +1,2 @@
"""pytest-splinter package."""
__version__ = '1.9.1'
__version__ = '1.9.2'
4 changes: 3 additions & 1 deletion pytest_splinter/plugin.py
Expand Up @@ -18,6 +18,8 @@
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
Expand Down Expand Up @@ -570,7 +572,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):
except (IOError, HTTPException, WebDriverException, MaxRetryError):
# we lost browser, try to restore the justice
try:
browser.quit()
Expand Down
13 changes: 8 additions & 5 deletions pytest_splinter/webdriver_patches.py
Expand Up @@ -8,9 +8,12 @@
import time # pragma: no cover
import socket # pragma: no cover
try:
from httplib import HTTPConnection, HTTPException
from httplib import HTTPException
except ImportError:
from http.client import HTTPConnection, HTTPException
from http.client import HTTPException

import urllib3
from urllib3.exceptions import MaxRetryError

from selenium.webdriver.remote import remote_connection # pragma: no cover
from selenium.webdriver.firefox import webdriver # pragma: no cover
Expand Down Expand Up @@ -39,12 +42,12 @@ def _request(self, *args, **kwargs):
for _ in range(3):
try:
return old_request(self, *args, **kwargs)
except (socket.error, HTTPException, IOError, OSError) as exc:
except (socket.error, HTTPException, IOError, OSError, MaxRetryError) as exc:
exception = exc
self._conn = HTTPConnection(self._conn.host, self._conn.port, timeout=self._timeout)
self._conn = urllib3.PoolManager(timeout=self._timeout)
raise exception

# Apply the monkey patche for RemoteConnection
# Apply the monkey patch for RemoteConnection
remote_connection.RemoteConnection._request = _request

# Apply the monkey patch to Firefox webdriver to disable native events
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -27,8 +27,9 @@
install_requires=[
'setuptools',
'splinter>=0.9.0',
'selenium>=2.47.1',
'selenium',
'pytest>=3.0.0',
'urllib3',
],
classifiers=[
'Development Status :: 6 - Mature',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -4,7 +4,7 @@ envlist=linters,py27,py27-xdist,py27-pytest-latest,py36
skip_missing_interpreters = true

[testenv]
commands= py.test tests --junitxml={envlogdir}/junit-{envname}.xml
commands= py.test {posargs} tests --junitxml={envlogdir}/junit-{envname}.xml
deps =
-e.
-r{toxinidir}/requirements-testing.txt
Expand Down

0 comments on commit ffd0f5c

Please sign in to comment.