Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

Issue 2512203002: Clean up style in layout_tests/models/test_expectations.py. (Closed)
Patch Set: Reformat literal dicts Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
index a8fc9eaac48820aa681a6f707b85a206dbcb1087..f424a25e333ad9fae9e55b3875fdb35f07d4857b 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
@@ -103,7 +103,7 @@ class TestExpectationParser(object):
def parse(self, filename, expectations_string):
expectation_lines = []
line_number = 0
- for line in expectations_string.split("\n"):
+ for line in expectations_string.split('\n'):
line_number += 1
test_expectation = TestExpectationLine.tokenize_line(filename, line, line_number)
self._parse_line(test_expectation)
@@ -229,7 +229,7 @@ class TestExpectationLine(object):
"""Initializes a blank-line equivalent of an expectation."""
self.original_string = None
self.filename = None # this is the path to the expectations file for this line
- self.line_numbers = "0"
+ self.line_numbers = '0'
self.name = None # this is the path in the line itself
self.path = None # this is the normpath of self.name
self.bugs = []
@@ -244,7 +244,7 @@ class TestExpectationLine(object):
self.is_extra_skipped_test = False
def __str__(self):
- return "TestExpectationLine{name=%s, matching_configurations=%s, original_string=%s}" % (
+ return 'TestExpectationLine{name=%s, matching_configurations=%s, original_string=%s}' % (
self.name, self.matching_configurations, self.original_string)
def __eq__(self, other):
@@ -276,7 +276,6 @@ class TestExpectationLine(object):
def is_whitespace(self):
return not self.original_string.strip()
-
# FIXME: Update the original specifiers and remove this once the old syntax is gone.
_configuration_tokens_list = [
'Mac', 'Mac10.9', 'Mac10.10', 'Mac10.11', 'Retina',
@@ -325,13 +324,13 @@ class TestExpectationLine(object):
expectation_line.filename = filename
expectation_line.line_numbers = str(line_number)
- comment_index = expectation_string.find("#")
+ comment_index = expectation_string.find('#')
if comment_index == -1:
comment_index = len(expectation_string)
else:
expectation_line.comment = expectation_string[comment_index + 1:]
- remaining_string = re.sub(r"\s+", " ", expectation_string[:comment_index].strip())
+ remaining_string = re.sub(r"\s+", ' ', expectation_string[:comment_index].strip())
if len(remaining_string) == 0:
return expectation_line
@@ -420,11 +419,11 @@ class TestExpectationLine(object):
warnings.append('A test marked Skip or WontFix must not have other expectations.')
if 'SLOW' in expectations and 'SlowTests' not in filename:
- warnings.append('SLOW tests should ony be added to SlowTests and not to TestExpectations.')
+ warnings.append('SLOW tests should only be added to SlowTests and not to TestExpectations.')
if 'WONTFIX' in expectations and ('NeverFixTests' not in filename and 'StaleTestExpectations' not in filename):
warnings.append(
- 'WONTFIX tests should ony be added to NeverFixTests or StaleTestExpectations and not to TestExpectations.')
+ 'WONTFIX tests should only be added to NeverFixTests or StaleTestExpectations and not to TestExpectations.')
if 'NeverFixTests' in filename and expectations != ['WONTFIX', 'SKIP']:
warnings.append('Only WONTFIX expectations are allowed in NeverFixTests')
@@ -438,7 +437,7 @@ class TestExpectationLine(object):
if 'MISSING' in expectations:
warnings.append(
'"Missing" expectations are not allowed; either download new baselines '
- '(see https://goo.gl/SHVYrZ) or use "NeedsRebaseline" expecatations.')
+ '(see https://goo.gl/SHVYrZ) or use "NeedsRebaseline" expectations.')
expectation_line.bugs = bugs
expectation_line.specifiers = specifiers
@@ -473,7 +472,7 @@ class TestExpectationLine(object):
# Not clear that there's anything better to do when not linting and the filenames are different.
if model_all_expectations:
result.filename = line2.filename
- result.line_numbers = line1.line_numbers + "," + line2.line_numbers
+ result.line_numbers = line1.line_numbers + ',' + line2.line_numbers
result.name = line1.name
result.path = line1.path
result.parsed_expectations = set(line1.parsed_expectations) | set(line2.parsed_expectations)
@@ -497,7 +496,7 @@ class TestExpectationLine(object):
return self.original_string or ''
if self.name is None:
- return '' if self.comment is None else "#%s" % self.comment
+ return '' if self.comment is None else '#%s' % self.comment
if test_configuration_converter and self.bugs:
specifiers_list = test_configuration_converter.to_specifiers_list(self.matching_configurations)
@@ -507,7 +506,7 @@ class TestExpectationLine(object):
specifiers = self._serialize_parsed_specifiers(test_configuration_converter, specifiers).split()
expectations = self._serialize_parsed_expectations(parsed_expectation_to_string).split()
result.append(self._format_line(self.bugs, specifiers, self.name, expectations, self.comment))
- return "\n".join(result) if result else None
+ return '\n'.join(result) if result else None
return self._format_line(self.bugs, self.specifiers, self.name, self.expectations, self.comment,
include_specifiers, include_expectations, include_comment)
@@ -562,7 +561,7 @@ class TestExpectationLine(object):
new_expectations = TestExpectationLine._filter_redundant_expectations(new_expectations)
result += ' [ %s ]' % ' '.join(sorted(set(new_expectations)))
if include_comment and comment is not None:
- result += " #%s" % comment
+ result += ' #%s' % comment
return result
@@ -626,13 +625,11 @@ class TestExpectationsModel(object):
self._merge_dict_of_sets(self._result_type_to_tests, other._result_type_to_tests)
def _dict_of_sets(self, strings_to_constants):
- """Takes a dict of strings->constants and returns a dict mapping
- each constant to an empty set.
- """
- d = {}
- for c in strings_to_constants.values():
- d[c] = set()
- return d
+ """Takes a dictionary of keys to values and returns a dict mapping each value to an empty set."""
+ result = {}
+ for value in strings_to_constants.values():
+ result[value] = set()
+ return result
def get_test_set(self, expectation, include_skips=True):
tests = self._expectation_to_tests[expectation]
@@ -683,7 +680,7 @@ class TestExpectationsModel(object):
for expectation in expectations:
retval.append(self.expectation_to_string(expectation))
- return " ".join(retval)
+ return ' '.join(retval)
def expectation_to_string(self, expectation):
"""Return the uppercased string equivalent of a given expectation."""
@@ -867,50 +864,57 @@ class TestExpectations(object):
"""
# FIXME: Update to new syntax once the old format is no longer supported.
- EXPECTATIONS = {'pass': PASS,
- 'audio': AUDIO,
- 'fail': FAIL,
- 'image': IMAGE,
- 'image+text': IMAGE_PLUS_TEXT,
- 'text': TEXT,
- 'timeout': TIMEOUT,
- 'crash': CRASH,
- 'leak': LEAK,
- 'missing': MISSING,
- TestExpectationParser.SKIP_MODIFIER: SKIP,
- TestExpectationParser.NEEDS_REBASELINE_MODIFIER: NEEDS_REBASELINE,
- TestExpectationParser.NEEDS_MANUAL_REBASELINE_MODIFIER: NEEDS_MANUAL_REBASELINE,
- TestExpectationParser.WONTFIX_MODIFIER: WONTFIX,
- TestExpectationParser.SLOW_MODIFIER: SLOW,
- TestExpectationParser.REBASELINE_MODIFIER: REBASELINE,
- }
+ EXPECTATIONS = {
+ 'pass': PASS,
+ 'audio': AUDIO,
+ 'fail': FAIL,
+ 'image': IMAGE,
+ 'image+text': IMAGE_PLUS_TEXT,
+ 'text': TEXT,
+ 'timeout': TIMEOUT,
+ 'crash': CRASH,
+ 'leak': LEAK,
+ 'missing': MISSING,
+ TestExpectationParser.SKIP_MODIFIER: SKIP,
+ TestExpectationParser.NEEDS_REBASELINE_MODIFIER: NEEDS_REBASELINE,
+ TestExpectationParser.NEEDS_MANUAL_REBASELINE_MODIFIER: NEEDS_MANUAL_REBASELINE,
+ TestExpectationParser.WONTFIX_MODIFIER: WONTFIX,
+ TestExpectationParser.SLOW_MODIFIER: SLOW,
+ TestExpectationParser.REBASELINE_MODIFIER: REBASELINE,
+ }
EXPECTATIONS_TO_STRING = dict((k, v) for (v, k) in EXPECTATIONS.iteritems())
# (aggregated by category, pass/fail/skip, type)
- EXPECTATION_DESCRIPTIONS = {SKIP: 'skipped',
- PASS: 'passes',
- FAIL: 'failures',
- IMAGE: 'image-only failures',
- TEXT: 'text-only failures',
- IMAGE_PLUS_TEXT: 'image and text failures',
- AUDIO: 'audio failures',
- CRASH: 'crashes',
- LEAK: 'leaks',
- TIMEOUT: 'timeouts',
- MISSING: 'missing results'}
+ EXPECTATION_DESCRIPTIONS = {
+ SKIP: 'skipped',
+ PASS: 'passes',
+ FAIL: 'failures',
+ IMAGE: 'image-only failures',
+ TEXT: 'text-only failures',
+ IMAGE_PLUS_TEXT: 'image and text failures',
+ AUDIO: 'audio failures',
+ CRASH: 'crashes',
+ LEAK: 'leaks',
+ TIMEOUT: 'timeouts',
+ MISSING: 'missing results',
+ }
NON_TEST_OUTCOME_EXPECTATIONS = (REBASELINE, SKIP, SLOW, WONTFIX)
BUILD_TYPES = ('debug', 'release')
- TIMELINES = {TestExpectationParser.WONTFIX_MODIFIER: WONTFIX,
- 'now': NOW}
+ TIMELINES = {
+ TestExpectationParser.WONTFIX_MODIFIER: WONTFIX,
+ 'now': NOW,
+ }
- RESULT_TYPES = {'skip': SKIP,
- 'pass': PASS,
- 'fail': FAIL,
- 'flaky': FLAKY}
+ RESULT_TYPES = {
+ 'skip': SKIP,
+ 'pass': PASS,
+ 'fail': FAIL,
+ 'flaky': FLAKY,
+ }
@classmethod
def expectation_from_string(cls, string):
@@ -1208,4 +1212,4 @@ class TestExpectations(object):
def nones_out(expectation_line):
return expectation_line is not None
- return "\n".join(filter(nones_out, map(serialize, expectation_lines)))
+ return '\n'.join(filter(nones_out, map(serialize, expectation_lines)))
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698