Fix remaining flake8 warnings

This commit is contained in:
Kagami Sascha Rosylight 2020-06-21 03:34:22 +02:00
parent c953931621
commit d01648d637
28 changed files with 328 additions and 310 deletions

View file

@ -31,44 +31,44 @@ def create_gecko_session():
def generate_placeholder(testcase):
# We need to still include the failed tests, otherwise Treeherder will
# consider the result to be a new test series, and thus a new graph. So we
# use a placeholder with values = -1 to make Treeherder happy, and still be
# able to identify failed tests (successful tests have time >=0).
# We need to still include the failed tests, otherwise Treeherder will
# consider the result to be a new test series, and thus a new graph. So we
# use a placeholder with values = -1 to make Treeherder happy, and still be
# able to identify failed tests (successful tests have time >=0).
timings = {
"testcase": testcase,
"title": ""
}
timings = {
"testcase": testcase,
"title": ""
}
timing_names = [
"navigationStart",
"unloadEventStart",
"domLoading",
"fetchStart",
"responseStart",
"loadEventEnd",
"connectStart",
"domainLookupStart",
"redirectStart",
"domContentLoadedEventEnd",
"requestStart",
"secureConnectionStart",
"connectEnd",
"loadEventStart",
"domInteractive",
"domContentLoadedEventStart",
"redirectEnd",
"domainLookupEnd",
"unloadEventEnd",
"responseEnd",
"domComplete",
]
timing_names = [
"navigationStart",
"unloadEventStart",
"domLoading",
"fetchStart",
"responseStart",
"loadEventEnd",
"connectStart",
"domainLookupStart",
"redirectStart",
"domContentLoadedEventEnd",
"requestStart",
"secureConnectionStart",
"connectEnd",
"loadEventStart",
"domInteractive",
"domContentLoadedEventStart",
"redirectEnd",
"domainLookupEnd",
"unloadEventEnd",
"responseEnd",
"domComplete",
]
for name in timing_names:
timings[name] = 0 if name == "navigationStart" else -1
for name in timing_names:
timings[name] = 0 if name == "navigationStart" else -1
return [timings]
return [timings]
def run_gecko_test(testcase, url, date, timeout, is_async):
@ -91,7 +91,7 @@ def run_gecko_test(testcase, url, date, timeout, is_async):
"return JSON.stringify(performance.timing)"
)
))
except:
except Exception:
# We need to return a timing object no matter what happened.
# See the comment in generate_placeholder() for explanation
print("Failed to get a valid timing measurement.")

View file

@ -116,7 +116,7 @@ def parse_log(log, testcase, url, date):
for line in block:
try:
(_, key, value) = line.split(",")
except:
except ValueError:
print("[DEBUG] failed to parse the following line:")
print(line)
print('[DEBUG] log:')
@ -133,10 +133,10 @@ def parse_log(log, testcase, url, date):
return timing
def valid_timing(timing, url=None):
if (timing is None or
testcase is None or
timing.get('title') == 'Error loading page' or
timing.get('testcase') != url):
if (timing is None
or testcase is None
or timing.get('title') == 'Error loading page'
or timing.get('testcase') != url):
return False
else:
return True

View file

@ -19,8 +19,8 @@ from runner import format_result_summary
def geometric_mean(iterable):
filtered = list(filter(lambda x: x > 0, iterable))
return (reduce(operator.mul, filtered)) ** (1.0 / len(filtered))
filtered = list(filter(lambda x: x > 0, iterable))
return (reduce(operator.mul, filtered)) ** (1.0 / len(filtered))
def format_testcase_name(name):

View file

@ -29,6 +29,7 @@ def load_data(filename):
results[key] = round(totals[key] / counts[key])
return results
data1 = load_data(args.file1)
data2 = load_data(args.file2)
keys = set(data1.keys()).union(data2.keys())

View file

@ -14,8 +14,8 @@ def test_format_testcase_name():
'http://localhost:8000/page_load_test/163.com/p.mail.163.com/'
'mailinfo/shownewmsg_www_1222.htm.html')))
assert(('1234567890223456789032345678904234567890'
'5234567890623456789072345678908234567890') ==
submit_to_perfherder.format_testcase_name((
'5234567890623456789072345678908234567890')
== submit_to_perfherder.format_testcase_name((
'1234567890223456789032345678904234567890'
'52345678906234567890723456789082345678909234567890')))
assert('news.ycombinator.com' == submit_to_perfherder.format_testcase_name(