Bug 1274167 - Add Linter(flake8) support for Firefox-ui and Puppeteer.r=whimboo
MozReview-Commit-ID: Ga3iaEH54yH
new file mode 100644
--- /dev/null
+++ b/testing/firefox-ui/.flake8
@@ -0,0 +1,3 @@
+[flake8]
+max-line-length = 99
+exclude = __init__.py,
--- a/testing/firefox-ui/tests/functional/security/test_mixed_content_page.py
+++ b/testing/firefox-ui/tests/functional/security/test_mixed_content_page.py
@@ -1,14 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from marionette_driver import Wait
-
from firefox_ui_harness.testcases import FirefoxTestCase
class TestMixedContentPage(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
self.locationbar = self.browser.navbar.locationbar
--- a/testing/firefox-ui/tests/functional/sessionstore/test_restore_windows_after_restart.py
+++ b/testing/firefox-ui/tests/functional/sessionstore/test_restore_windows_after_restart.py
@@ -120,17 +120,16 @@ class TestRestoreWindowsAfterRestart(Fir
win = self.browser
for index, urls in enumerate(window_sets):
if index > 0:
win = self.browser.open_browser(is_private=is_private)
win.switch_to()
self.open_tabs(win, urls)
-
def open_tabs(self, win, urls):
""" Opens a set of URLs inside a window in new tabs.
@param win (browser window)
The browser window to load the tabs in.
@param urls (tuple)
A tuple of URLs to load in this window. The
first URL will be loaded in the currently selected
--- a/testing/firefox-ui/tests/puppeteer/test_appinfo.py
+++ b/testing/firefox-ui/tests/puppeteer/test_appinfo.py
@@ -1,15 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import mozversion
-from marionette_driver.errors import MarionetteException
-
from firefox_ui_harness.testcases import FirefoxTestCase
class TestAppInfo(FirefoxTestCase):
def test_valid_properties(self):
binary = self.marionette.bin
version_info = mozversion.get_version(binary=binary)
--- a/testing/firefox-ui/tests/puppeteer/test_menubar.py
+++ b/testing/firefox-ui/tests/puppeteer/test_menubar.py
@@ -8,18 +8,16 @@ from firefox_ui_harness.testcases import
class TestMenuBar(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
def test_click_item_in_menubar(self):
- num_tabs = len(self.browser.tabbar.tabs)
-
def opener(_):
self.browser.menubar.select_by_id('file-menu',
'menu_newNavigatorTab')
self.browser.tabbar.open_tab(trigger=opener)
self.browser.tabbar.tabs[-1].close()
--- a/testing/firefox-ui/tests/puppeteer/test_page_info_window.py
+++ b/testing/firefox-ui/tests/puppeteer/test_page_info_window.py
@@ -1,13 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from marionette_driver import By
from firefox_ui_harness.testcases import FirefoxTestCase
class TestPageInfoWindow(FirefoxTestCase):
def tearDown(self):
try:
self.windows.close_all([self.browser])
new file mode 100644
--- /dev/null
+++ b/testing/puppeteer/.flake8
@@ -0,0 +1,3 @@
+[flake8]
+max-line-length = 99
+exclude = __init__.py,
--- a/testing/puppeteer/firefox/firefox_puppeteer/testcases/base.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/testcases/base.py
@@ -34,26 +34,26 @@ class BaseFirefoxTestCase(unittest.TestC
def __init__(self, *args, **kwargs):
super(BaseFirefoxTestCase, self).__init__(*args, **kwargs)
def _check_and_fix_leaked_handles(self):
handle_count = len(self.marionette.window_handles)
url = []
try:
- #Verify the existence of leaked tabs and print their URLs.
+ # Verify the existence of leaked tabs and print their URLs.
if self._start_handle_count < handle_count:
message = ('A test must not leak window handles. This test started with '
'%s open top level browsing contexts, but ended with %s.'
- ' Remaining Tabs URLs:') % (self._start_handle_count , handle_count)
+ ' Remaining Tabs URLs:') % (self._start_handle_count, handle_count)
with self.marionette.using_context('content'):
for tab in self.marionette.window_handles:
if tab not in self._init_tab_handles:
url.append(' %s' % self.marionette.get_url())
- self.assertListEqual(self._init_tab_handles , self.marionette.window_handles ,
+ self.assertListEqual(self._init_tab_handles, self.marionette.window_handles,
message + ','.join(url))
finally:
# For clean-up make sure we work on a proper browser window
if not self.browser or self.browser.closed:
# Find a proper replacement browser window
# TODO: We have to make this less error prone in case no browser is open.
self.browser = self.windows.switch_to(lambda win: type(win) is BrowserWindow)
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
@@ -1,36 +1,26 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
-import firefox_puppeteer.errors as errors
-
from marionette_driver import By, Wait
-from marionette_driver.errors import (
- NoSuchElementException,
- NoSuchWindowException)
-from marionette_driver.keys import Keys
-
-from firefox_puppeteer.api.l10n import L10n
-from firefox_puppeteer.api.prefs import Preferences
-from firefox_puppeteer.decorators import use_class_as_property
+from marionette_driver.errors import NoSuchElementException
from firefox_puppeteer.ui.about_window.window import AboutWindow
from firefox_puppeteer.ui.browser.notifications import (
AddOnInstallBlockedNotification,
AddOnInstallConfirmationNotification,
AddOnInstallCompleteNotification,
AddOnInstallFailedNotification,
AddOnProgressNotification,
BaseNotification)
from firefox_puppeteer.ui.browser.tabbar import TabBar
from firefox_puppeteer.ui.browser.toolbars import NavBar
from firefox_puppeteer.ui.pageinfo.window import PageInfoWindow
from firefox_puppeteer.ui.windows import BaseWindow, Windows
-import firefox_puppeteer.errors as errors
class BrowserWindow(BaseWindow):
"""Representation of a browser window."""
window_type = 'navigator:browser'
dtds = [
--- a/tools/lint/flake8.lint
+++ b/tools/lint/flake8.lint
@@ -118,17 +118,19 @@ def lint(files, **lintargs):
return results
LINTER = {
'name': "flake8",
'description': "Python linter",
'include': [
'python/mozlint',
+ 'taskcluster',
+ 'testing/firefox-ui',
+ 'testing/marionette/client',
+ 'testing/puppeteer',
+ 'testing/talos/',
'tools/lint',
- 'taskcluster',
- 'testing/marionette/client',
- 'testing/talos/',
],
'exclude': [],
'type': 'external',
'payload': lint,
}