Bug 1274167 - Add Linter(flake8) support for Firefox-ui and Puppeteer.r=whimboo draft
authorPiyush Sinha <sinha.piyush0609@gmail.com>
Mon, 15 Aug 2016 02:16:18 +0530
changeset 400827 264c275f6e4bf8feaa2a65479aba43ca1e2cd27e
parent 400532 b274d6e85690c468b5f97dce27c92835f2b8168d
child 528335 70da3a8db5e0dc5ef8fa3952c785f25547539d37
push id26290
push userbmo:sinha.piyush0609@gmail.com
push dateMon, 15 Aug 2016 22:17:13 +0000
reviewerswhimboo
bugs1274167
milestone51.0a1
Bug 1274167 - Add Linter(flake8) support for Firefox-ui and Puppeteer.r=whimboo MozReview-Commit-ID: Ga3iaEH54yH
testing/firefox-ui/.flake8
testing/firefox-ui/tests/functional/security/test_mixed_content_page.py
testing/firefox-ui/tests/functional/sessionstore/test_restore_windows_after_restart.py
testing/firefox-ui/tests/puppeteer/test_appinfo.py
testing/firefox-ui/tests/puppeteer/test_menubar.py
testing/firefox-ui/tests/puppeteer/test_page_info_window.py
testing/puppeteer/.flake8
testing/puppeteer/firefox/firefox_puppeteer/testcases/base.py
testing/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
tools/lint/flake8.lint
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,
 }