Bug 1397853 - Enable py2 and py3 linter on testing/mochitest. r=ahal
☠☠ backed out by 16813d52b75c ☠ ☠
authorSteve Armand <stevea1@mac.com>
Sun, 24 Sep 2017 21:28:25 -0400
changeset 383465 dbe60b600dc0b9aabce3d197b438e4a6816f117e
parent 383464 13dcb717827363acb5ab0f83952acf15d70e7269
child 383466 35460a8966c7e32c45407cb9a2a333d20b120875
push id32594
push userkwierso@gmail.com
push dateThu, 28 Sep 2017 22:49:33 +0000
treeherdermozilla-central@6dea0ee45b66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1397853
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1397853 - Enable py2 and py3 linter on testing/mochitest. r=ahal MozReview-Commit-ID: EhkNhyFHDox
testing/mochitest/bisection.py
testing/mochitest/leaks.py
testing/mochitest/mach_commands.py
testing/mochitest/mach_test_package_commands.py
testing/mochitest/mochitest_options.py
testing/mochitest/pywebsocket_wrapper.py
testing/mochitest/rungeckoview.py
testing/mochitest/runrobocop.py
testing/mochitest/runtests.py
testing/mochitest/runtestsremote.py
testing/mochitest/tests/python/conftest.py
testing/mochitest/tests/python/test_basic_mochitest_plain.py
testing/mochitest/tests/python/test_get_active_tests.py
tools/lint/py2.yml
tools/lint/py3.yml
--- a/testing/mochitest/bisection.py
+++ b/testing/mochitest/bisection.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import, print_function
+
 import math
 import mozinfo
 
 
 class Bisect(object):
 
     "Class for creating, bisecting and summarizing for --bisect-chunk option."
 
@@ -270,11 +272,11 @@ class Bisect(object):
                 self.summary.append(
                     "TEST-UNEXPECTED-FAIL | %s | Bleedthrough detected, this test is the "
                     "root cause for many of the above failures" %
                     self.contents['testsToRun'][0])
                 return -1
 
     def print_summary(self):
         "This method is used to print the recorded summary."
-        print "Bisection summary:"
+        print("Bisection summary:")
         for line in self.summary:
-            print line
+            print(line)
--- a/testing/mochitest/leaks.py
+++ b/testing/mochitest/leaks.py
@@ -1,15 +1,17 @@
 # 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/
 
 # The content of this file comes orginally from automationutils.py
 # and *should* be revised.
 
+from __future__ import absolute_import, print_function
+
 import re
 from operator import itemgetter
 
 
 class ShutdownLeaks(object):
 
     """
     Parses the mochitest run log when running a debug build, assigns all leaked
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -1,13 +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/.
 
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 
 from argparse import Namespace
 from collections import defaultdict
 import logging
 import os
 import sys
 import warnings
 
--- a/testing/mochitest/mach_test_package_commands.py
+++ b/testing/mochitest/mach_test_package_commands.py
@@ -1,13 +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/.
 
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
 
 import os
 from argparse import Namespace
 from functools import partial
 
 from mach.decorators import (
     CommandProvider,
     Command,
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -1,12 +1,14 @@
 # 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 __future__ import absolute_import
+
 from abc import ABCMeta, abstractmethod, abstractproperty
 from argparse import ArgumentParser, SUPPRESS
 from distutils.util import strtobool
 from itertools import chain
 from urlparse import urlparse
 import logging
 import json
 import os
--- a/testing/mochitest/pywebsocket_wrapper.py
+++ b/testing/mochitest/pywebsocket_wrapper.py
@@ -4,16 +4,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 
 """A wrapper around pywebsocket's standalone.py which causes it to ignore
 SIGINT.
 
 """
 
+from __future__ import absolute_import
+
 import signal
 import sys
 
 if __name__ == '__main__':
     sys.path = ['pywebsocket'] + sys.path
     import standalone
 
     # If we received --interactive as the first argument, ignore SIGINT so
--- a/testing/mochitest/rungeckoview.py
+++ b/testing/mochitest/rungeckoview.py
@@ -1,12 +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/.
 
+from __future__ import absolute_import, print_function
 
 import posixpath
 import shutil
 import sys
 import tempfile
 import time
 import traceback
 from optparse import OptionParser
@@ -187,18 +188,18 @@ class GeckoviewTestRunner:
                 if self.dm.dirExists(remote_dir):
                     crash_dir_found = True
                     break
             if not crash_dir_found:
                 # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the
                 # minidumps directory is automatically created when the app
                 # (first) starts, so its lack of presence is a hint that
                 # something went wrong.
-                print "Automation Error: No crash directory (%s) found on remote device" % \
-                    remote_dir
+                print("Automation Error: No crash directory (%s) found on remote device" %
+                      remote_dir)
                 # Whilst no crash was found, the run should still display as a failure
                 return True
             self.dm.getDirectory(remote_dir, dump_dir)
             crashed = mozcrash.log_crashes(self.log, dump_dir, symbols_path, test=self.test_name)
         finally:
             try:
                 shutil.rmtree(dump_dir)
             except:
--- a/testing/mochitest/runrobocop.py
+++ b/testing/mochitest/runrobocop.py
@@ -1,12 +1,14 @@
 # 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 __future__ import absolute_import, print_function
+
 import json
 import os
 import sys
 import tempfile
 import traceback
 from collections import defaultdict
 
 sys.path.insert(
@@ -525,19 +527,19 @@ class RobocopTestRunner(MochitestDesktop
             result = self.runSingleTest(test)
             if worstTestResult is None or worstTestResult == 0:
                 worstTestResult = result
         if worstTestResult is None:
             self.log.warning(
                 "No tests run. Did you pass an invalid TEST_PATH?")
             worstTestResult = 1
         else:
-            print "INFO | runtests.py | Test summary: start."
+            print("INFO | runtests.py | Test summary: start.")
             logResult = self.logTestSummary()
-            print "INFO | runtests.py | Test summary: end."
+            print("INFO | runtests.py | Test summary: end.")
             if worstTestResult == 0:
                 worstTestResult = logResult
         return worstTestResult
 
 
 def run_test_harness(parser, options):
     parser.validate(options)
 
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1,17 +1,18 @@
 # 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/.
 
 """
 Runs the Mochitest test harness.
 """
 
-from __future__ import with_statement
+from __future__ import absolute_import, print_function, with_statement
+
 import os
 import sys
 SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
 sys.path.insert(0, SCRIPT_DIR)
 
 from argparse import Namespace
 from collections import defaultdict
 from contextlib import closing
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -1,12 +1,14 @@
 # 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 __future__ import absolute_import
+
 import os
 import sys
 import traceback
 
 sys.path.insert(
     0, os.path.abspath(
         os.path.realpath(
             os.path.dirname(__file__))))
--- a/testing/mochitest/tests/python/conftest.py
+++ b/testing/mochitest/tests/python/conftest.py
@@ -1,13 +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/.
 
-from __future__ import print_function, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 import json
 import os
 from argparse import Namespace
 from cStringIO import StringIO
 
 import pytest
 
 import mozinfo
--- a/testing/mochitest/tests/python/test_basic_mochitest_plain.py
+++ b/testing/mochitest/tests/python/test_basic_mochitest_plain.py
@@ -1,12 +1,14 @@
 # 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 __future__ import absolute_import
+
 import os
 from functools import partial
 
 import mozunit
 import pytest
 from moztest.selftest.output import get_mozharness_status, filter_action
 
 from mozharness.base.log import INFO, WARNING, ERROR
--- a/testing/mochitest/tests/python/test_get_active_tests.py
+++ b/testing/mochitest/tests/python/test_get_active_tests.py
@@ -1,13 +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/.
 
-from __future__ import print_function, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 from argparse import Namespace
 
 from manifestparser import TestManifest
 
 import mozunit
 import pytest
--- a/tools/lint/py2.yml
+++ b/tools/lint/py2.yml
@@ -36,17 +36,17 @@ py2:
         - services/common/tests/mach_commands.py
         - servo
         - testing/awsy
         - testing/firefox-ui
         - testing/geckodriver
         - testing/gtest
         - testing/instrumentation/runinstrumentation.py
         - testing/marionette
-        - testing/mochitest
+        - testing/mochitest/pywebsocket
         - testing/mozbase
         - testing/mozharness
         - testing/remotecppunittests.py
         - testing/runcppunittests.py
         - testing/runtimes
         - testing/tools
         - testing/tps
         - testing/web-platform
--- a/tools/lint/py3.yml
+++ b/tools/lint/py3.yml
@@ -27,17 +27,17 @@ py3:
         - security/manager/ssl
         - security/nss
         - services/common/tests/mach_commands.py
         - servo
         - testing/awsy
         - testing/firefox-ui/harness/firefox_ui_harness/runners/update.py
         - testing/gtest
         - testing/marionette
-        - testing/mochitest
+        - testing/mochitest/pywebsocket
         - testing/mozbase
         - testing/mozharness
         - testing/tools/iceserver
         - testing/tps
         - testing/xpcshell
         - testing/web-platform
         - third_party
         - toolkit