From 9e125ea7106db9f19f8cc2ce06d3db1d2a7fe015 Mon Sep 17 00:00:00 2001 From: Bob Clary Date: Fri, 11 Dec 2020 16:05:25 +0000 Subject: [PATCH] Bug 1681096 - python3 - pylint --py3k - W1619: from __future__ import division r=marionette-reviewers,perftest-reviewers,gbrown Differential Revision: https://phabricator.services.mozilla.com/D98938 --- testing/awsy/awsy/process_perf_data.py | 5 ++++- testing/condprofile/condprof/progress.py | 4 +++- testing/condprofile/condprof/util.py | 4 ++-- testing/gtest/bench.py | 4 ++-- testing/jsshell/benchmark.py | 6 +++++- testing/marionette/client/marionette_driver/gestures.py | 4 +++- .../client/marionette_driver/legacy_actions.py | 4 +++- .../marionette/client/marionette_driver/marionette.py | 3 ++- .../marionette_harness/tests/unit/test_mouse_action.py | 3 ++- testing/mochitest/bisection.py | 3 ++- testing/mochitest/leaks.py | 3 +++ testing/mochitest/pywebsocket3/mod_pywebsocket/stream.py | 4 ++++ testing/mochitest/runtests.py | 3 ++- testing/mozbase/manifestparser/manifestparser/filters.py | 4 +++- testing/mozbase/mozdevice/mozdevice/adb.py | 3 ++- .../mozgeckoprofiler/mozgeckoprofiler/symbolication.py | 3 ++- .../mozbase/mozlog/mozlog/formatters/tbplformatter.py | 3 ++- testing/mozbase/mozlog/mozlog/formatters/unittest.py | 3 ++- testing/mozbase/mozpower/mozpower/intel_power_gadget.py | 7 ++++++- testing/mozbase/mozpower/mozpower/mozpowerutils.py | 3 ++- testing/mozbase/mozprofile/tests/test_profile.py | 3 ++- .../mozrunner/mozrunner/devices/emulator_battery.py | 3 ++- testing/mozbase/mozrunner/mozrunner/utils.py | 4 +++- .../mozsystemmonitor/mozsystemmonitor/resourcemonitor.py | 5 ++++- testing/mozharness/mozharness/base/diskutils.py | 2 ++ testing/mozharness/mozharness/base/python.py | 2 ++ .../scripts/release/update-verify-config-creator.py | 2 ++ testing/raptor/raptor/browsertime/base.py | 4 +++- testing/raptor/raptor/cpu.py | 6 ++++-- testing/raptor/raptor/filters.py | 9 +++++++-- testing/raptor/raptor/output.py | 4 +++- testing/raptor/raptor/power.py | 4 +++- testing/raptor/raptor/webextension/base.py | 4 +++- testing/raptor/test/test_cpu.py | 3 ++- testing/talos/talos/filter.py | 4 +++- testing/talos/talos/heavy.py | 3 ++- testing/talos/talos/output.py | 3 ++- testing/talos/talos/scripts/report.py | 4 +++- testing/testinfo.py | 4 +++- testing/tps/tps/testrunner.py | 3 ++- testing/xpcshell/mach_commands.py | 3 ++- testing/xpcshell/runxpcshelltests.py | 3 ++- 42 files changed, 117 insertions(+), 41 deletions(-) diff --git a/testing/awsy/awsy/process_perf_data.py b/testing/awsy/awsy/process_perf_data.py index 38fd148a2eac..e6dfe51485aa 100644 --- a/testing/awsy/awsy/process_perf_data.py +++ b/testing/awsy/awsy/process_perf_data.py @@ -3,7 +3,7 @@ # 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 +from __future__ import absolute_import, division, print_function import os import sys @@ -54,10 +54,12 @@ PERF_SUITES = [ def median(values): sorted_ = sorted(values) + # pylint --py3k W1619 med = int(len(sorted_) / 2) if len(sorted_) % 2: return sorted_[med] + # pylint --py3k W1619 return (sorted_[med - 1] + sorted_[med]) / 2 @@ -173,6 +175,7 @@ def create_suite( # Add the geometric mean. For more details on the calculation see: # https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms + # pylint --py3k W1619 suite["value"] = math.exp(total / len(checkpoints)) return suite diff --git a/testing/condprofile/condprof/progress.py b/testing/condprofile/condprof/progress.py index 9fb6c1f0c0c4..b95713a9c972 100644 --- a/testing/condprofile/condprof/progress.py +++ b/testing/condprofile/condprof/progress.py @@ -22,7 +22,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -from __future__ import absolute_import +from __future__ import absolute_import, division import sys import time @@ -92,6 +92,7 @@ class Bar(object): self.last_progress = progress if (time.time() - self.etadelta) > ETA_INTERVAL: self.etadelta = time.time() + # pylint --py3k W1619 self.ittimes = self.ittimes[-ETA_SMA_WINDOW:] + [ -(self.start - time.time()) / (progress + 1) ] @@ -101,6 +102,7 @@ class Bar(object): * (self.expected_size - progress) ) self.etadisp = self.format_time(self.eta) + # pylint --py3k W1619 x = int(self.width * progress / self.expected_size) if not self.hide: if (progress % self.every) == 0 or ( # True every "every" updates diff --git a/testing/condprofile/condprof/util.py b/testing/condprofile/condprof/util.py index 6fd09327c4e2..6dfdc7d5265e 100644 --- a/testing/condprofile/condprof/util.py +++ b/testing/condprofile/condprof/util.py @@ -4,8 +4,7 @@ # # This module needs to stay Python 2 and 3 compatible # -from __future__ import absolute_import -from __future__ import print_function +from __future__ import absolute_import, division, print_function import platform import time @@ -245,6 +244,7 @@ def download_file(url, target=None): f.flush() else: iter = req.iter_content(chunk_size=1024) + # pylint --py3k W1619 size = total_length / 1024 + 1 for chunk in progress.bar(iter, expected_size=size): if chunk: diff --git a/testing/gtest/bench.py b/testing/gtest/bench.py index 715027fbc484..e6050c39ba89 100755 --- a/testing/gtest/bench.py +++ b/testing/gtest/bench.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -from __future__ import print_function - +from __future__ import division, print_function import sys import subprocess import json @@ -13,6 +12,7 @@ for line in proc.stdout: data = json.loads(line[len("PERFHERDER_DATA:") :].decode("utf8")) for suite in data["suites"]: for subtest in suite["subtests"]: + # pylint --py3k W1619 print( "%4d.%03d ± %6s ms %s.%s" % ( diff --git a/testing/jsshell/benchmark.py b/testing/jsshell/benchmark.py index 704e931131a1..09b4f5170510 100644 --- a/testing/jsshell/benchmark.py +++ b/testing/jsshell/benchmark.py @@ -2,7 +2,7 @@ # 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 +from __future__ import absolute_import, division, print_function import json import os @@ -137,6 +137,7 @@ class RunOnceBenchmark(Benchmark): for bench, scores in self.scores.items(): for score, values in scores.items(): test_name = "{}-{}".format(self.name, score) + # pylint --py3k W1619 mean = sum(values) / len(values) self.suite["subtests"].append({"name": test_name, "value": mean}) bench_total += int(sum(values)) @@ -193,6 +194,7 @@ class Ares6(Benchmark): def collect_results(self): for bench, scores in self.scores.items(): for score, values in scores.items(): + # pylint --py3k W1619 mean = sum(values) / len(values) test_name = "{}-{}".format(bench, score) self.suite["subtests"].append({"name": test_name, "value": mean}) @@ -296,6 +298,7 @@ class WebToolingBenchmark(Benchmark): for bench, scores in self.scores.items(): for score_name, values in scores.items(): test_name = "{}-{}".format(self.name, score_name) + # pylint --py3k W1619 mean = sum(values) / len(values) self.suite["subtests"].append( { @@ -348,6 +351,7 @@ class Octane(RunOnceBenchmark): for bench, scores in self.scores.items(): for score_name, values in scores.items(): test_name = "{}-{}".format(self.name, score_name) + # pylint --py3k W1619 mean = sum(values) / len(values) self.suite["subtests"].append({"name": test_name, "value": mean}) if score_name == "score": diff --git a/testing/marionette/client/marionette_driver/gestures.py b/testing/marionette/client/marionette_driver/gestures.py index fa4023a130e9..90645c856423 100644 --- a/testing/marionette/client/marionette_driver/gestures.py +++ b/testing/marionette/client/marionette_driver/gestures.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division from .legacy_actions import MultiActions, Actions @@ -70,6 +70,7 @@ def pinch(marionette_session, element, x1, y1, x2, y2, x3, y3, x4, y4, duration= time_increment = 10 if time_increment >= duration: time_increment = duration + # pylint --py3k W1619 move_x1 = time_increment * 1.0 / duration * (x3 - x1) move_y1 = time_increment * 1.0 / duration * (y3 - y1) move_x2 = time_increment * 1.0 / duration * (x4 - x2) @@ -81,6 +82,7 @@ def pinch(marionette_session, element, x1, y1, x2, y2, x3, y3, x4, y4, duration= action2.press(element, x2, y2) while time < duration: time += time_increment + # pylint --py3k W1619 action1.move_by_offset(move_x1, move_y1).wait(time_increment / 1000) action2.move_by_offset(move_x2, move_y2).wait(time_increment / 1000) action1.release() diff --git a/testing/marionette/client/marionette_driver/legacy_actions.py b/testing/marionette/client/marionette_driver/legacy_actions.py index cebf84df2100..d77a373a2066 100644 --- a/testing/marionette/client/marionette_driver/legacy_actions.py +++ b/testing/marionette/client/marionette_driver/legacy_actions.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division from . import errors from .marionette import MouseButton @@ -218,12 +218,14 @@ class Actions(object): time_increment = 10 if time_increment >= duration: time_increment = duration + # pylint --py3k W1619 move_x = time_increment * 1.0 / duration * (x2 - x1) move_y = time_increment * 1.0 / duration * (y2 - y1) self.action_chain.append(["press", element, x1, y1]) while elapsed < duration: elapsed += time_increment self.action_chain.append(["moveByOffset", move_x, move_y]) + # pylint --py3k W1619 self.action_chain.append(["wait", time_increment / 1000]) self.action_chain.append(["release"]) return self diff --git a/testing/marionette/client/marionette_driver/marionette.py b/testing/marionette/client/marionette_driver/marionette.py index a88da5703742..b9123cac1122 100644 --- a/testing/marionette/client/marionette_driver/marionette.py +++ b/testing/marionette/client/marionette_driver/marionette.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division import base64 import datetime @@ -1195,6 +1195,7 @@ class Marionette(object): timeout = self.session.get("moz:shutdownTimeout") if timeout is not None: + # pylint --py3k W1619 self.shutdown_timeout = timeout / 1000 + 10 return self.session diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py b/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py index a23e918446a5..a27965964aa3 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division from six.moves.urllib.parse import quote @@ -45,6 +45,7 @@ class BaseMouseAction(MarionetteTestCase): ) def get_element_center_point(self, elem): + # pylint --py3k W1619 return { "x": elem.rect["x"] + elem.rect["width"] / 2, "y": elem.rect["y"] + elem.rect["height"] / 2, diff --git a/testing/mochitest/bisection.py b/testing/mochitest/bisection.py index 5d269c847218..17ab5776fccb 100644 --- a/testing/mochitest/bisection.py +++ b/testing/mochitest/bisection.py @@ -1,4 +1,4 @@ -from __future__ import print_function +from __future__ import division, print_function import math import mozinfo @@ -139,6 +139,7 @@ class Bisect(object): self.contents["start"] = 0 self.contents["end"] = totalTests - 2 + # pylint --py3k W1619 mid = (self.contents["start"] + self.contents["end"]) / 2 if "result" in self.contents: if self.contents["result"] == "PASS": diff --git a/testing/mochitest/leaks.py b/testing/mochitest/leaks.py index dde13c6198e6..623faa8f6f09 100644 --- a/testing/mochitest/leaks.py +++ b/testing/mochitest/leaks.py @@ -5,6 +5,8 @@ # The content of this file comes orginally from automationutils.py # and *should* be revised. +from __future__ import division + import re from operator import itemgetter @@ -153,6 +155,7 @@ class ShutdownLeaks(object): # Note: to figure out how many hidden windows were created, we divide # this number by 2, because 1 hidden window creation implies in # 1 outer window + 1 inner window. + # pylint --py3k W1619 self.logger.info( "TEST-INFO | %s | This test created %d hidden window(s)" % (test["fileName"], test["hiddenWindowsCount"] / 2) diff --git a/testing/mochitest/pywebsocket3/mod_pywebsocket/stream.py b/testing/mochitest/pywebsocket3/mod_pywebsocket/stream.py index fc399f2a85b9..17c51b11b423 100644 --- a/testing/mochitest/pywebsocket3/mod_pywebsocket/stream.py +++ b/testing/mochitest/pywebsocket3/mod_pywebsocket/stream.py @@ -33,6 +33,8 @@ Specification: http://tools.ietf.org/html/rfc6455 """ +from __future__ import division + from collections import deque import logging import os @@ -272,6 +274,7 @@ def parse_frame(receive_bytes, raw_payload_bytes = receive_bytes(payload_length) if logger.isEnabledFor(common.LOGLEVEL_FINE): + # pylint --py3k W1619 logger.log( common.LOGLEVEL_FINE, 'Done receiving payload data at %s MB/s', payload_length / (time.time() - receive_start) / 1000 / 1000) @@ -283,6 +286,7 @@ def parse_frame(receive_bytes, unmasked_bytes = masker.mask(raw_payload_bytes) if logger.isEnabledFor(common.LOGLEVEL_FINE): + # pylint --py3k W1619 logger.log(common.LOGLEVEL_FINE, 'Done unmasking payload data at %s MB/s', payload_length / (time.time() - unmask_start) / 1000 / 1000) diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index 40f937cf04e2..445241804de9 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -6,7 +6,7 @@ Runs the Mochitest test harness. """ -from __future__ import print_function, with_statement +from __future__ import division, print_function, with_statement import os import sys @@ -357,6 +357,7 @@ class MessageLogger(object): last_timestamp = None for buf in dumped_messages: + # pylint --py3k W1619 timestamp = datetime.fromtimestamp(buf["time"] / 1000).strftime("%H:%M:%S") if timestamp != last_timestamp: self.logger.info("Buffered messages logged at {}".format(timestamp)) diff --git a/testing/mozbase/manifestparser/manifestparser/filters.py b/testing/mozbase/manifestparser/manifestparser/filters.py index e0ef58f8f98b..3a5dc955e043 100644 --- a/testing/mozbase/manifestparser/manifestparser/filters.py +++ b/testing/mozbase/manifestparser/manifestparser/filters.py @@ -8,7 +8,7 @@ dictionary of values, and returns a new iterable of test objects. It is possible to define custom filters if the built-in ones are not enough. """ -from __future__ import absolute_import +from __future__ import absolute_import, division import itertools import os @@ -362,6 +362,7 @@ class chunk_by_runtime(InstanceFilter): # Compute the average to use as a default for manifests that don't exist. times = [r[0] for r in runtimes] + # pylint --py3k W1619 avg = round(sum(times) / len(times), 2) if times else 0 missing = sorted([m for m in manifests if m not in self.runtimes]) log( @@ -392,6 +393,7 @@ class chunk_by_runtime(InstanceFilter): manifests = set(self.get_manifest(t) for t in tests) chunks = self.get_chunked_manifests(manifests) runtime, this_manifests = chunks[self.this_chunk - 1] + # pylint --py3k W1619 log( "Cumulative test runtime is around {} minutes (average is {} minutes)".format( round(runtime / 60), diff --git a/testing/mozbase/mozdevice/mozdevice/adb.py b/testing/mozbase/mozdevice/mozdevice/adb.py index f67b3f6b217f..1f2e789e3b84 100644 --- a/testing/mozbase/mozdevice/mozdevice/adb.py +++ b/testing/mozbase/mozdevice/mozdevice/adb.py @@ -2,7 +2,7 @@ # 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 +from __future__ import absolute_import, division, print_function import io import os @@ -3401,6 +3401,7 @@ class ADBDevice(ADBCommand): elif parameter == "scale": scale = float(value) if parameter is not None and scale is not None: + # pylint --py3k W1619 percentage = 100.0 * level / scale break return percentage diff --git a/testing/mozbase/mozgeckoprofiler/mozgeckoprofiler/symbolication.py b/testing/mozbase/mozgeckoprofiler/mozgeckoprofiler/symbolication.py index 5266d4c833a2..3f2cdd8ce36b 100644 --- a/testing/mozbase/mozgeckoprofiler/mozgeckoprofiler/symbolication.py +++ b/testing/mozbase/mozgeckoprofiler/mozgeckoprofiler/symbolication.py @@ -1,7 +1,7 @@ # 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 __future__ import absolute_import, division import hashlib import os @@ -312,6 +312,7 @@ class ProfileSymbolicator: left = 0 right = len(libs) - 1 while left <= right: + # pylint --py3k W1619 mid = (left + right) / 2 if address >= libs[mid]["end"]: left = mid + 1 diff --git a/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py b/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py index af2c5b4c9cc5..f47989492db2 100644 --- a/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py +++ b/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division import functools from collections import deque @@ -307,6 +307,7 @@ class TbplFormatter(BaseFormatter): def suite_end(self, data): start_time = self.suite_start_time + # pylint --py3k W1619 time = int((data["time"] - start_time) / 1000) return "SUITE-END | took %is\n" % time diff --git a/testing/mozbase/mozlog/mozlog/formatters/unittest.py b/testing/mozbase/mozlog/mozlog/formatters/unittest.py index 99a31d19e606..6abc3d476597 100755 --- a/testing/mozbase/mozlog/mozlog/formatters/unittest.py +++ b/testing/mozbase/mozlog/mozlog/formatters/unittest.py @@ -4,7 +4,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from __future__ import absolute_import +from __future__ import absolute_import, division from . import base @@ -78,6 +78,7 @@ class UnittestFormatter(base.BaseFormatter): return "\n".join("ERROR %(test)s\n%(message)s" % data for data in self.errors) def output_summary(self): + # pylint --py3k W1619 return "Ran %i tests in %.1fs" % ( self.tests_run, (self.end_time - self.start_time) / 1000, diff --git a/testing/mozbase/mozpower/mozpower/intel_power_gadget.py b/testing/mozbase/mozpower/mozpower/intel_power_gadget.py index 114a5125477d..f6a32ac9ed73 100644 --- a/testing/mozbase/mozpower/mozpower/intel_power_gadget.py +++ b/testing/mozbase/mozpower/mozpower/intel_power_gadget.py @@ -1,7 +1,7 @@ # 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, division, unicode_literals import csv import os @@ -548,6 +548,7 @@ class IPGResultsHandler(object): # exist in the file and that the columns have the correct # data type. column_datatypes = {"System Time": str, "RDTSC": int, "default": float} + # pylint --py3k W1619 expected_samples = int( self._ipg_measure_duration / (float(self._sampling_rate) / 1000) ) @@ -694,6 +695,7 @@ class IPGResultsHandler(object): ) # Check that the combined results have the expected number of samples. + # pylint W16919 expected_samples = int( self._ipg_measure_duration / (float(self._sampling_rate) / 1000) ) @@ -817,6 +819,7 @@ class IPGResultsHandler(object): watt_usage = {} for measure in cut_results: if "watt" in measure.lower() and "limit" not in measure.lower(): + # pylint --py3k W1619 watt_usage[replace_measure_name(measure) + "-avg"] = sum( [float(val) for val in cut_results[measure]] ) / len(cut_results[measure]) @@ -839,6 +842,7 @@ class IPGResultsHandler(object): elif "gt " in utilized_name: utilized_name = "gpu" + # pylint --py3k W1619 average_utilization[utilized_name] = sum( [float(val) for val in cut_results[utilization]] ) / len(cut_results[utilization]) @@ -857,6 +861,7 @@ class IPGResultsHandler(object): fmeasure_name = "cpu" elif "gt " in fmeasure_name: fmeasure_name = "gpu" + # pylint --py3k W1619 frequency_info[fmeasure_name]["favg"] = sum( [float(val) for val in cut_results[frequency_measure]] diff --git a/testing/mozbase/mozpower/mozpower/mozpowerutils.py b/testing/mozbase/mozpower/mozpower/mozpowerutils.py index 3f90bd4e7a74..8a781c9b8857 100644 --- a/testing/mozbase/mozpower/mozpower/mozpowerutils.py +++ b/testing/mozbase/mozpower/mozpower/mozpowerutils.py @@ -1,7 +1,7 @@ # 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, division, unicode_literals def get_logger(logger_name): @@ -32,6 +32,7 @@ def average_summary(values): :param list values: list of values to average. :returns: float """ + # pylint --py3k W1619 return sum([float(v[0]) for v in values]) / len(values) diff --git a/testing/mozbase/mozprofile/tests/test_profile.py b/testing/mozbase/mozprofile/tests/test_profile.py index 65872fb72897..20aaf959de01 100644 --- a/testing/mozbase/mozprofile/tests/test_profile.py +++ b/testing/mozbase/mozprofile/tests/test_profile.py @@ -4,7 +4,7 @@ # 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 __future__ import absolute_import, division import os @@ -35,6 +35,7 @@ def test_with_profile_should_cleanup(): def test_with_profile_should_cleanup_even_on_exception(): with pytest.raises(ZeroDivisionError): + # pylint --py3k W1619 with Profile() as profile: assert os.path.exists(profile.profile) 1 / 0 # will raise ZeroDivisionError diff --git a/testing/mozbase/mozrunner/mozrunner/devices/emulator_battery.py b/testing/mozbase/mozrunner/mozrunner/devices/emulator_battery.py index 8c399d9ca414..88380e8276fd 100644 --- a/testing/mozbase/mozrunner/mozrunner/devices/emulator_battery.py +++ b/testing/mozbase/mozrunner/mozrunner/devices/emulator_battery.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division class EmulatorBattery(object): @@ -26,6 +26,7 @@ class EmulatorBattery(object): value = float(value) status[field] = value + # pylint --py3k W1619 state["level"] = status.get("capacity", 0.0) / 100 if status.get("AC") == "online": state["charging"] = True diff --git a/testing/mozbase/mozrunner/mozrunner/utils.py b/testing/mozbase/mozrunner/mozrunner/utils.py index d960a00b5b55..27334eb2492f 100755 --- a/testing/mozbase/mozrunner/mozrunner/utils.py +++ b/testing/mozbase/mozrunner/mozrunner/utils.py @@ -6,7 +6,7 @@ """Utility functions for mozrunner""" -from __future__ import absolute_import, print_function +from __future__ import absolute_import, division, print_function import os import sys @@ -170,6 +170,7 @@ def test_environment( # Returns total system memory in kilobytes. if mozinfo.isWin: + # pylint --py3k W1619 totalMemory = ( int( os.popen( @@ -179,6 +180,7 @@ def test_environment( / 1024 ) elif mozinfo.isMac: + # pylint --py3k W1619 totalMemory = ( int(os.popen("sysctl hw.memsize").readlines()[0].split()[1]) / 1024 ) diff --git a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py index 17e31517a8dd..eb7b8ffb5dd0 100644 --- a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py +++ b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division from contextlib import contextmanager import multiprocessing @@ -527,10 +527,12 @@ class SystemResourceMonitor(object): return 0 if per_cpu: + # pylint --py3k W1619 return [sum(x) / samples for x in cpu] cores = [sum(x) for x in cpu] + # pylint --py3k W1619 return sum(cores) / len(cpu) / samples def aggregate_cpu_times(self, start=None, end=None, phase=None, per_cpu=True): @@ -672,6 +674,7 @@ class SystemResourceMonitor(object): def populate_derived(e): if e["cpu_percent_cores"]: + # pylint --py3k W1619 e["cpu_percent_mean"] = sum(e["cpu_percent_cores"]) / len( e["cpu_percent_cores"] ) diff --git a/testing/mozharness/mozharness/base/diskutils.py b/testing/mozharness/mozharness/base/diskutils.py index a5effb7dfae5..81f4d8d4aa68 100644 --- a/testing/mozharness/mozharness/base/diskutils.py +++ b/testing/mozharness/mozharness/base/diskutils.py @@ -28,6 +28,7 @@ pass """ +from __future__ import division import ctypes import logging import os @@ -67,6 +68,7 @@ def convert_to(size, from_unit, to_unit): try: df = sizes[to_unit] sf = sizes[from_unit] + # pylint --py3k W1619 return size * sf / df except KeyError: raise DiskutilsError("conversion error: Invalid source or destination format") diff --git a/testing/mozharness/mozharness/base/python.py b/testing/mozharness/mozharness/base/python.py index ccd36ef6211c..1f777324152f 100644 --- a/testing/mozharness/mozharness/base/python.py +++ b/testing/mozharness/mozharness/base/python.py @@ -7,6 +7,7 @@ """Python usage, esp. virtualenv. """ +from __future__ import division import errno import json import os @@ -835,6 +836,7 @@ class ResourceMonitoringMixin(PerfherderResourceOptionsMixin): for attr in cpu_attrs: value = getattr(cpu_times, attr) # cpu_total can be 0.0. Guard against division by 0. + # pylint --py3k W1619 percent = value / cpu_total * 100.0 if cpu_total else 0.0 if percent > 1.00: diff --git a/testing/mozharness/scripts/release/update-verify-config-creator.py b/testing/mozharness/scripts/release/update-verify-config-creator.py index 92bb8f852300..b22f30b88402 100644 --- a/testing/mozharness/scripts/release/update-verify-config-creator.py +++ b/testing/mozharness/scripts/release/update-verify-config-creator.py @@ -2,6 +2,7 @@ # 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 division from distutils.version import LooseVersion import json import math @@ -39,6 +40,7 @@ def is_triangualar(x): >>> all(not is_triangualar(x) for x in [4, 5, 8, 9, 11, 17, 25, 29, 39, 44, 59, 61, 72, 98, 112]) True """ + # pylint --py3k W1619 n = (math.sqrt(8 * x + 1) - 1) / 2 return n == int(n) diff --git a/testing/raptor/raptor/browsertime/base.py b/testing/raptor/raptor/browsertime/base.py index 26d844633a02..8a75f80ee073 100644 --- a/testing/raptor/raptor/browsertime/base.py +++ b/testing/raptor/raptor/browsertime/base.py @@ -4,7 +4,7 @@ # 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 __future__ import absolute_import, division from abc import ABCMeta, abstractmethod @@ -322,11 +322,13 @@ class Browsertime(Perftest): # bt_timeout will be the overall browsertime cmd/session timeout (seconds) # browsertime deals with page cycles internally, so we need to give it a timeout # value that includes all page cycles + # pylint --py3k W1619 bt_timeout = int(timeout / 1000) * int(test.get("page_cycles", 1)) # the post-startup-delay is a delay after the browser has started, to let it settle # it's handled within browsertime itself by loading a 'preUrl' (about:blank) and having a # delay after that ('preURLDelay') as the post-startup-delay, so we must add that in sec + # pylint --py3k W1619 bt_timeout += int(self.post_startup_delay / 1000) # add some time for browser startup, time for the browsertime measurement code diff --git a/testing/raptor/raptor/cpu.py b/testing/raptor/raptor/cpu.py index 159b1666aff2..1290d2ffbcb6 100644 --- a/testing/raptor/raptor/cpu.py +++ b/testing/raptor/raptor/cpu.py @@ -1,7 +1,7 @@ # 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 __future__ import absolute_import, division import time import threading @@ -132,7 +132,9 @@ class AndroidCPUProfiler(object): u"type": u"cpu", u"test": test_name + "-avg", u"unit": u"%", - u"values": {u"avg": sum(self.polls) / len(self.polls)}, + u"values": { + u"avg": sum(self.polls) / len(self.polls) + }, # pylint --py3k W1619 } self.raptor.control_server.submit_supporting_data(avg_cpuinfo_data) diff --git a/testing/raptor/raptor/filters.py b/testing/raptor/raptor/filters.py index e2baec9226b2..7cf7d6debb1a 100644 --- a/testing/raptor/raptor/filters.py +++ b/testing/raptor/raptor/filters.py @@ -4,7 +4,7 @@ # originally taken from /testing/talos/talos/filter.py -from __future__ import absolute_import +from __future__ import absolute_import, division import math @@ -120,9 +120,12 @@ def median(series): series = sorted(series) if len(series) % 2: # odd - return series[len(series) / 2] + # pylint --py3k W1619 + # must force to int to use as index. + return series[int(len(series) / 2)] else: # even + # pylint --py3k W1619 middle = int(len(series) / 2) # the higher of the middle 2, actually return 0.5 * (series[middle - 1] + series[middle]) @@ -181,6 +184,7 @@ def geometric_mean(series): total = 0 for i in series: total += math.log(i + 1) + # pylint --py3k W1619 return math.exp(total / len(series)) - 1 @@ -269,6 +273,7 @@ def v8_subtest(series, name): "Splay": 81491.0, } + # pylint --py3k W1619 return reference[name] / geometric_mean(series) diff --git a/testing/raptor/raptor/output.py b/testing/raptor/raptor/output.py index 5b8fd377b247..70822b6b472a 100644 --- a/testing/raptor/raptor/output.py +++ b/testing/raptor/raptor/output.py @@ -5,7 +5,7 @@ # some parts of this originally taken from /testing/talos/talos/output.py """output raptor test results""" -from __future__ import absolute_import, print_function +from __future__ import absolute_import, division, print_function import filters @@ -334,6 +334,7 @@ class PerftestOutput(object): ) results = results[9::10] + # pylint --py3k W1619 score = 60 * 1000 / filters.geometric_mean(results) / correctionFactor return score @@ -379,6 +380,7 @@ class PerftestOutput(object): "StyleBench requires 380 entries, found: %s instead" % len(results) ) results = results[75::76] + # pylint --py3k W1619 return 60 * 1000 / filters.geometric_mean(results) / correctionFactor if testname.startswith(("raptor-kraken", "raptor-sunspider")): diff --git a/testing/raptor/raptor/power.py b/testing/raptor/raptor/power.py index 484ae114009d..b87260bb71a8 100644 --- a/testing/raptor/raptor/power.py +++ b/testing/raptor/raptor/power.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division import os import re @@ -358,6 +358,7 @@ def finish_android_power_test(raptor, test_name, os_baseline=False): if not baseline_measure: LOG.error("Power test baseline_measure is Zero.") return 0 + # pylint --py3k W1619 return ( 100 * ((power_measure + baseline_measure) / baseline_measure) ) - 100 @@ -369,6 +370,7 @@ def finish_android_power_test(raptor, test_name, os_baseline=False): "values": {}, } for power_measure in power_data["values"]: + # pylint --py3k W1619 pc_power_data["values"][power_measure] = calculate_pc( (power_data["values"][power_measure] / test_time), raptor.os_baseline_data["values"][power_measure], diff --git a/testing/raptor/raptor/webextension/base.py b/testing/raptor/raptor/webextension/base.py index ad1165ebf473..045082faa17f 100644 --- a/testing/raptor/raptor/webextension/base.py +++ b/testing/raptor/raptor/webextension/base.py @@ -4,7 +4,7 @@ # 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 __future__ import absolute_import, division import json import os @@ -73,9 +73,11 @@ class WebExtension(Perftest): # we don't want this timeout occurring unless abosultely necessary # convert timeout to seconds and account for page cycles + # pylint --py3k W1619 timeout = int(timeout / 1000) * int(test.get("page_cycles", 1)) # account for the pause the raptor webext runner takes after browser startup # and the time an exception is propagated through the framework + # pylint --py3k W1619 timeout += int(self.post_startup_delay / 1000) + 10 # for page-load tests we don't start the page-timeout timer until the pageload.js content diff --git a/testing/raptor/test/test_cpu.py b/testing/raptor/test/test_cpu.py index e50dbb2d1724..1737dd6c4320 100644 --- a/testing/raptor/test/test_cpu.py +++ b/testing/raptor/test/test_cpu.py @@ -1,7 +1,7 @@ # 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, division, unicode_literals import os @@ -165,6 +165,7 @@ def test_usage_with_fallback(): cpu_profiler.polls.append(0) # Verify the response contains our expected CPU % of 8 + # pylint --py3k W1619 avg_cpuinfo_data = { "type": "cpu", "test": "usage_with_fallback-avg", diff --git a/testing/talos/talos/filter.py b/testing/talos/talos/filter.py index 37918bb3c7d0..be67067100be 100644 --- a/testing/talos/talos/filter.py +++ b/testing/talos/talos/filter.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division import math import six @@ -180,6 +180,7 @@ def geometric_mean(series): total = 0 for i in series: total += math.log(i + 1) + # pylint --py3k W1619 return math.exp(total / len(series)) - 1 @@ -254,6 +255,7 @@ def v8_subtest(series, name): "Splay": 81491.0, } + # pylint --py3k W1619 return reference[name] / geometric_mean(series) diff --git a/testing/talos/talos/heavy.py b/testing/talos/talos/heavy.py index c45deef82bfe..273961230e35 100644 --- a/testing/talos/talos/heavy.py +++ b/testing/talos/talos/heavy.py @@ -5,7 +5,7 @@ """ Downloads Heavy profiles from TaskCluster. """ -from __future__ import absolute_import +from __future__ import absolute_import, division import os import tarfile import functools @@ -121,6 +121,7 @@ def download_profile(name, profiles_dir=None): template = "Download progress %d%%" with open(archive_file, "wb") as f: iter = req.iter_content(chunk_size=1024) + # pylint --py3k W1619 size = total_length / 1024 + 1 with ProgressBar(size=size, template=template) as bar: for chunk in iter: diff --git a/testing/talos/talos/output.py b/testing/talos/talos/output.py index 89e3880adeb0..62d619c076c9 100644 --- a/testing/talos/talos/output.py +++ b/testing/talos/talos/output.py @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. """output formats for Talos""" -from __future__ import absolute_import +from __future__ import absolute_import, division from talos import filter @@ -310,6 +310,7 @@ class Output(object): ) results = results[75::76] + # pylint --py3k W1619 score = 60 * 1000 / filter.geometric_mean(results) / correctionFactor return score diff --git a/testing/talos/talos/scripts/report.py b/testing/talos/talos/scripts/report.py index 3b17fbb930bb..bee954004e4a 100644 --- a/testing/talos/talos/scripts/report.py +++ b/testing/talos/talos/scripts/report.py @@ -2,7 +2,7 @@ # 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 __future__ import absolute_import, division import argparse import collections @@ -77,6 +77,7 @@ def generate_report(tuple_list, filepath, mode="variance"): for day in day_name: if mode == "variance": # removing top and bottom 10% to reduce outlier influence + # pylint --py3k W1619 tenth = len(days[day]) / 10 average = numpy.average(sorted(days[day])[tenth : tenth * 9 + 1]) elif mode == "count": @@ -116,6 +117,7 @@ def is_normal(y): clean_week = y # look at weekends now + # pylint --py3k W1619 avg = sum(clean_week) / len(clean_week) for i in six.moves.range(5, 7): # look for something outside of the 20% window diff --git a/testing/testinfo.py b/testing/testinfo.py index 893484c992f9..e700cc79deff 100644 --- a/testing/testinfo.py +++ b/testing/testinfo.py @@ -2,7 +2,7 @@ # 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 +from __future__ import absolute_import, division, print_function import datetime import errno @@ -530,6 +530,7 @@ class TestInfoLongRunningTasks(TestInfo): def get_long_running_ratio(record): count = record["count"] tasks_gt_pct = record["tasks_gt_pct"] + # pylint --py3k W1619 return count / tasks_gt_pct # Search test durations in ActiveData for long-running tests @@ -589,6 +590,7 @@ class TestInfoLongRunningTasks(TestInfo): count = record["count"] max_run_time = record["max_run_time"] tasks_gt_pct = record["tasks_gt_pct"] + # pylint --py3k W1619 print( "%-55s: %d of %d runs (%.1f%%) exceeded %d%% of max-run-time (%d s)" % ( diff --git a/testing/tps/tps/testrunner.py b/testing/tps/tps/testrunner.py index 089d9c97c82a..3c0b312cc5c9 100644 --- a/testing/tps/tps/testrunner.py +++ b/testing/tps/tps/testrunner.py @@ -2,7 +2,7 @@ # 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 +from __future__ import absolute_import, division, print_function import json import yaml @@ -211,6 +211,7 @@ class TPSTestRunner(object): possible_time = line[0:13] if len(possible_time) == 13 and possible_time.isdigit(): time_ms = int(possible_time) + # pylint --py3k W1619 formatted = time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time_ms / 1000), diff --git a/testing/xpcshell/mach_commands.py b/testing/xpcshell/mach_commands.py index 81cd94f14ae1..731563b0dc9c 100644 --- a/testing/xpcshell/mach_commands.py +++ b/testing/xpcshell/mach_commands.py @@ -4,7 +4,7 @@ # Integrates the xpcshell test runner with mach. -from __future__ import absolute_import, unicode_literals, print_function +from __future__ import absolute_import, division, print_function, unicode_literals import errno import logging @@ -260,6 +260,7 @@ class MachCommands(MachCommandBase): ) if not params["threadCount"]: + # pylint --py3k W1619 params["threadCount"] = int((cpu_count() * 3) / 2) if conditions.is_android(self) or self.substs.get("MOZ_BUILD_APP") == "b2g": diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py index 2deafde23ebb..be967c71b50a 100755 --- a/testing/xpcshell/runxpcshelltests.py +++ b/testing/xpcshell/runxpcshelltests.py @@ -4,7 +4,7 @@ # 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 +from __future__ import absolute_import, division, print_function import copy import json @@ -1656,6 +1656,7 @@ class XPCShellTests(object): ): # TSan requires significantly more memory, so reduce the amount of parallel # tests we run to avoid OOMs and timeouts. + # pylint --py3k W1619 self.threadCount = self.threadCount / 2 self.stack_fixer_function = None