Skip to content

Commit

Permalink
[py] Fix flake8 issues and run flake8 on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt committed Nov 13, 2016
1 parent fa51776 commit bc19742
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 15 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ matrix:
- language: java
jdk: oraclejdk8
env: TASK=javadocs
- language: python
python: 2.7
env: TOXENV=flake8
- language: python
python: 2.7
env: TOXENV=docs
- language: python
python: 2.7
env: CHROME=1 TOXENV=py27-chrome
Expand All @@ -114,7 +120,10 @@ matrix:
addons:
firefox: latest
- language: python
python: 2.7
python: 3.5
env: TOXENV=flake8
- language: python
python: 3.5
env: TOXENV=docs
- language: python
python: 3.5
Expand All @@ -137,9 +146,6 @@ matrix:
env: TOXENV=py35-remote
addons:
firefox: latest
- language: python
python: 3.5
env: TOXENV=docs
- language: ruby
rvm: 2.2.3
jdk: oraclejdk8
Expand Down
9 changes: 7 additions & 2 deletions py/selenium/webdriver/firefox/firefox_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ def __init__(self, firefox_path=None, log_file=None):
if self._start_cmd is None:
self._start_cmd = self._get_firefox_start_cmd()
if not self._start_cmd.strip():
raise WebDriverException("Failed to find firefox binary. You can set it by specifying the path to 'firefox_binary':\n\nfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinary\n\n" +
"binary = FirefoxBinary('/path/to/binary')\ndriver = webdriver.Firefox(firefox_binary=binary)")
raise WebDriverException(
"Failed to find firefox binary. You can set it by specifying "
"the path to 'firefox_binary':\n\nfrom "
"selenium.webdriver.firefox.firefox_binary import "
"FirefoxBinary\n\nbinary = "
"FirefoxBinary('/path/to/binary')\ndriver = "
"webdriver.Firefox(firefox_binary=binary)")
# Rather than modifying the environment of the calling Python process
# copy it and modify as needed.
self._firefox_env = os.environ.copy()
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/firefox/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def binary(self, new_binary):
def binary_location(self):
return self.binary

@binary.setter
@binary.setter # noqa
def binary_location(self, value):
self.binary = value

Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/firefox/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Service(service.Service):
GeckoDriver."""

def __init__(self, executable_path, port=0, service_args=None,
log_path="geckodriver.log", env=None):
log_path="geckodriver.log", env=None):
"""Creates a new instance of the GeckoDriver remote service proxy.
GeckoDriver provides a HTTP interface speaking the W3C WebDriver
Expand Down
1 change: 0 additions & 1 deletion py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import shutil
import socket
import sys
import types

from .extension_connection import ExtensionConnection
from contextlib import contextmanager
Expand Down
6 changes: 4 additions & 2 deletions py/selenium/webdriver/firefox/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def anonymous_children(self):
on MDN for more information.
"""
return self._execute("ELEMENT_GET_ANONYMOUS_CHILDREN",
return self._execute(
"ELEMENT_GET_ANONYMOUS_CHILDREN",
{"value": None})

def find_anonymous_element_by_attribute(self, name, value):
Expand All @@ -43,5 +44,6 @@ def find_anonymous_element_by_attribute(self, name, value):
on MDN for more information.
"""
return self._execute("ELEMENT_FIND_ANONYMOUS_ELEMENTS_BY_ATTRIBUTE",
return self._execute(
"ELEMENT_FIND_ANONYMOUS_ELEMENTS_BY_ATTRIBUTE",
{"name": name, "value": value})["value"]
1 change: 0 additions & 1 deletion py/selenium/webdriver/safari/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
except ImportError:
import httplib as http_client

import os
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
from .service import Service
Expand Down
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/common/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
def get_interface_ip(ifname):
def _bytes(value, encoding):
try:
return bytes(value, encoding) # Python 3
return bytes(value, encoding) # Python 3
except TypeError:
return value # Python 2
return value # Python 2

sckt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{27,35}-{chrome,edge,firefox,ie,phantomjs,remote,safari}, docs
envlist = py{27,35}-{chrome,edge,firefox,ie,phantomjs,remote,safari}, docs, flake8

[testenv]
passenv = DISPLAY PYTEST_ADDOPTS
Expand Down Expand Up @@ -27,3 +27,8 @@ deps =
Pygments==1.6
Sphinx==1.2b1
commands = sphinx-build -W -b html -d build/doctrees py/docs/source build/docs/api/py {posargs}

[testenv:flake8]
skip_install = true
deps = flake8
commands = flake8 {posargs:py}

0 comments on commit bc19742

Please sign in to comment.