Remove invalid-string-quote from //testing Removes the invalid-string-quote disable from the //testing pylintrc file and fixes all resulting errors. Bug: 353942917 Change-Id: I4e8ef60d4f7b7645fee7ee86d579032bb0c24eb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5784807 Commit-Queue: Ben Pastene <bpastene@chromium.org> Auto-Submit: Brian Sheedy <bsheedy@chromium.org> Reviewed-by: Ben Pastene <bpastene@chromium.org> Commit-Queue: Brian Sheedy <bsheedy@chromium.org> Cr-Commit-Position: refs/heads/main@{#1341341}
diff --git a/testing/buildbot/check.py b/testing/buildbot/check.py index b156543c..e92e645 100755 --- a/testing/buildbot/check.py +++ b/testing/buildbot/check.py
@@ -147,7 +147,7 @@ parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__) parser.parse_args() - with open(os.path.join(THIS_DIR, "gn_isolate_map.pyl")) as fp: + with open(os.path.join(THIS_DIR, 'gn_isolate_map.pyl')) as fp: gn_isolate_map = ast.literal_eval(fp.read()) ninja_targets = {k: v['label'] for k, v in gn_isolate_map.items()} @@ -177,5 +177,5 @@ return 1 -if __name__ == "__main__": +if __name__ == '__main__': sys.exit(main())
diff --git a/testing/buildbot/generate_buildbot_json.py b/testing/buildbot/generate_buildbot_json.py index 3174b911..b5b1f42 100755 --- a/testing/buildbot/generate_buildbot_json.py +++ b/testing/buildbot/generate_buildbot_json.py
@@ -286,28 +286,27 @@ group.add_argument( '--query', type=str, - help=( - "Returns raw JSON information of buildbots and tests.\n" + - "Examples:\n" + " List all bots (all info):\n" + - " --query bots\n\n" + - " List all bots and only their associated tests:\n" + - " --query bots/tests\n\n" + - " List all information about 'bot1' " + - "(make sure you have quotes):\n" + " --query bot/'bot1'\n\n" + - " List tests running for 'bot1' (make sure you have quotes):\n" + - " --query bot/'bot1'/tests\n\n" + " List all tests:\n" + - " --query tests\n\n" + - " List all tests and the bots running them:\n" + - " --query tests/bots\n\n" + - " List all tests that satisfy multiple parameters\n" + - " (separation of parameters by '&' symbol):\n" + - " --query tests/'device_os:Android&device_type:hammerhead'\n\n" + - " List all tests that run with a specific flag:\n" + - " --query bots/'--test-launcher-print-test-studio=always'\n\n" + - " List specific test (make sure you have quotes):\n" - " --query test/'test1'\n\n" - " List all bots running 'test1' " + - "(make sure you have quotes):\n" + " --query test/'test1'/bots")) + help=('Returns raw JSON information of buildbots and tests.\n' + 'Examples:\n List all bots (all info):\n' + ' --query bots\n\n' + ' List all bots and only their associated tests:\n' + ' --query bots/tests\n\n' + ' List all information about "bot1" ' + '(make sure you have quotes):\n --query bot/"bot1"\n\n' + ' List tests running for "bot1" (make sure you have quotes):\n' + ' --query bot/"bot1"/tests\n\n List all tests:\n' + ' --query tests\n\n' + ' List all tests and the bots running them:\n' + ' --query tests/bots\n\n' + ' List all tests that satisfy multiple parameters\n' + ' (separation of parameters by "&" symbol):\n' + ' --query tests/"device_os:Android&device_type:hammerhead"\n\n' + ' List all tests that run with a specific flag:\n' + ' --query bots/"--test-launcher-print-test-studio=always"\n\n' + ' List specific test (make sure you have quotes):\n' + ' --query test/"test1"\n\n' + ' List all bots running "test1" ' + '(make sure you have quotes):\n --query test/"test1"/bots')) parser.add_argument( '--json', metavar='JSON_FILE_PATH', @@ -362,7 +361,7 @@ args = parser.parse_args(argv) if args.json and not args.query: parser.error( - "The --json flag can only be used with --query.") # pragma: no cover + 'The --json flag can only be used with --query.') # pragma: no cover args.pyl_files_dir = args.pyl_files_dir or THIS_DIR args.output_dir = args.output_dir or args.pyl_files_dir @@ -648,7 +647,7 @@ # Apply mixins from the builder builder_mixins = builder.get('mixins', []) self.ensure_valid_mixin_list(builder_mixins, - f"builder {builder_name} mixins") + f'builder {builder_name} mixins') test = self.apply_mixins(test, builder_mixins, mixins_to_ignore, builder) # See if there are any exceptions that need to be merged into this @@ -853,7 +852,7 @@ result['cros_board'] = tester_config.get('cros_board') or result.get( 'cros_board') else: - raise BBGenErr("skylab tests must specify cros_board.") + raise BBGenErr('skylab tests must specify cros_board.') if 'cros_model' in result or 'cros_model' in tester_config: result['cros_model'] = tester_config.get('cros_model') or result.get( 'cros_model') @@ -1490,7 +1489,7 @@ for field in required_fields: # Verify required fields if field not in waterfall: - raise BBGenErr("Waterfall %s has no %s" % (waterfall['name'], field)) + raise BBGenErr('Waterfall %s has no %s' % (waterfall['name'], field)) # Handle filter flag, if specified if filters and waterfall['name'] not in filters: @@ -1737,7 +1736,7 @@ """ if not isinstance(node, typ): if verbose: - lines = [""] + self.read_file(file_path).splitlines() + lines = [''] + self.read_file(file_path).splitlines() context = 2 lines_start = max(node.lineno - context, 0) @@ -1745,7 +1744,7 @@ lines_end = min(node.lineno + context, len(lines)) + 1 lines = itertools.chain( ['== %s ==\n' % file_path], - ["<snip>\n"], + ['<snip>\n'], [ '%d %s' % (lines_start + i, line) for i, line in enumerate(lines[lines_start:lines_start + @@ -1761,7 +1760,7 @@ '%d %s' % (node.lineno + 1 + i, line) for i, line in enumerate(lines[node.lineno + 1:lines_end]) ], - ["<snip>\n"], + ['<snip>\n'], ) # Print out a useful message when a type assertion fails. for l in lines: @@ -1773,7 +1772,7 @@ if len(node_dumped) > 60: # pragma: no cover node_dumped = node_dumped[:30] + ' <SNIP> ' + node_dumped[-30:] raise BBGenErr( - 'Invalid .pyl file \'%s\'. Python AST node %r on line %s expected to' + "Invalid .pyl file '%s'. Python AST node %r on line %s expected to" ' be %s, is %s' % (file_path, node_dumped, node.lineno, typ, type(node))) @@ -1905,7 +1904,7 @@ val, self.args.waterfalls_pyl_path, verbose): bad_files.add(self.args.waterfalls_pyl_path) - if key.s == "name": + if key.s == 'name': self.type_assert(val, ast.Str, self.args.waterfalls_pyl_path, verbose) waterfall_name = val assert waterfall_name @@ -2166,16 +2165,16 @@ params_dict = {} for p in params: # flag - if p.startswith("--"): + if p.startswith('--'): params_dict[p] = True else: - pair = p.split(":") + pair = p.split(':') if len(pair) != 2: self.error_msg('Invalid command.') # regular parameters - if pair[1].lower() == "true": + if pair[1].lower() == 'true': params_dict[pair[0]] = True - elif pair[1].lower() == "false": + elif pair[1].lower() == 'false': params_dict[pair[0]] = False else: params_dict[pair[0]] = pair[1] @@ -2225,7 +2224,7 @@ cmd_class = query[0] # For queries starting with 'bots' - if cmd_class == "bots": + if cmd_class == 'bots': if len(query) == 1: return self.output_query_result(bots, args.json) # query with specific parameters @@ -2233,35 +2232,35 @@ if query[1] == 'tests': test_suites_dict = self.get_test_suites_dict(bots) return self.output_query_result(test_suites_dict, args.json) - self.error_msg("This query should be in the format: bots/tests.") + self.error_msg('This query should be in the format: bots/tests.') else: - self.error_msg("This query should have 0 or 1 '/', found %s instead." - % str(len(query)-1)) + self.error_msg('This query should have 0 or 1 "/"", found %s instead.' % + str(len(query) - 1)) # For queries starting with 'bot' - elif cmd_class == "bot": + elif cmd_class == 'bot': if not len(query) == 2 and not len(query) == 3: - self.error_msg("Command should have 1 or 2 '/', found %s instead." - % str(len(query)-1)) + self.error_msg('Command should have 1 or 2 "/"", found %s instead.' % + str(len(query) - 1)) bot_id = query[1] if not bot_id in bots: - self.error_msg("No bot named '" + bot_id + "' found.") + self.error_msg('No bot named "' + bot_id + '" found.') bot_info = bots[bot_id] if len(query) == 2: return self.output_query_result(bot_info, args.json) if not query[2] == 'tests': - self.error_msg("The query should be in the format:" + - "bot/<bot-name>/tests.") + self.error_msg('The query should be in the format:' + 'bot/<bot-name>/tests.') bot_tests = self.flatten_tests_for_bot(bot_info) return self.output_query_result(bot_tests, args.json) # For queries starting with 'tests' - elif cmd_class == "tests": + elif cmd_class == 'tests': if not len(query) == 1 and not len(query) == 2: - self.error_msg("The query should have 0 or 1 '/', found %s instead." - % str(len(query)-1)) + self.error_msg('The query should have 0 or 1 "/", found %s instead.' % + str(len(query) - 1)) flattened_tests = self.flatten_tests_for_query(tests) if len(query) == 1: return self.output_query_result(flattened_tests, args.json) @@ -2273,26 +2272,27 @@ return self.output_query_result(matching_bots) # For queries starting with 'test' - elif cmd_class == "test": + elif cmd_class == 'test': if not len(query) == 2 and not len(query) == 3: - self.error_msg("The query should have 1 or 2 '/', found %s instead." - % str(len(query)-1)) + self.error_msg('The query should have 1 or 2 "/", found %s instead.' % + str(len(query) - 1)) test_id = query[1] if len(query) == 2: flattened_tests = self.flatten_tests_for_query(tests) for test in flattened_tests: if test == test_id: return self.output_query_result(flattened_tests[test], args.json) - self.error_msg("There is no test named %s." % test_id) + self.error_msg('There is no test named %s.' % test_id) if not query[2] == 'bots': - self.error_msg("The query should be in the format: " + - "test/<test-name>/bots") + self.error_msg('The query should be in the format: ' + 'test/<test-name>/bots') bots_for_test = self.find_bots_that_run_test(test_id, bots) return self.output_query_result(bots_for_test) else: - self.error_msg("Your command did not match any valid commands." + - "Try starting with 'bots', 'bot', 'tests', or 'test'.") + self.error_msg('Your command did not match any valid commands. ' + 'Try starting with "bots", "bot", "tests", or "test".') + # pylint: enable=inconsistent-return-statements def main(self): # pragma: no cover @@ -2304,6 +2304,7 @@ self.write_json_result(self.generate_outputs()) return 0 -if __name__ == "__main__": # pragma: no cover + +if __name__ == '__main__': # pragma: no cover generator = BBJSONGenerator(BBJSONGenerator.parse_args(sys.argv[1:])) sys.exit(generator.main())
diff --git a/testing/buildbot/generate_buildbot_json_unittest.py b/testing/buildbot/generate_buildbot_json_unittest.py index 7429bca..f36c574 100755 --- a/testing/buildbot/generate_buildbot_json_unittest.py +++ b/testing/buildbot/generate_buildbot_json_unittest.py
@@ -3040,157 +3040,157 @@ } """ TEST_QUERY_BOTS_OUTPUT = { - "Fake Android M Tester": { - "gtest_tests": [{ - "name": "foo_test", - "test": "foo_test", + 'Fake Android M Tester': { + 'gtest_tests': [{ + 'name': 'foo_test', + 'test': 'foo_test', }] }, - "Fake Android L Tester": { - "gtest_tests": [{ - "test": - "foo_test", - "args": [ - "--gs-results-bucket=chromium-result-details", - "--recover-devices" + 'Fake Android L Tester': { + 'gtest_tests': [{ + 'test': + 'foo_test', + 'args': [ + '--gs-results-bucket=chromium-result-details', + '--recover-devices' ], - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" + 'merge': { + 'script': '//testing/merge_scripts/standard_gtest_merge.py' }, - "name": - "foo_test", - "swarming": { - "dimensions": { - "device_os": "LMY41U", - "device_os_type": "user", - "device_type": "hammerhead", + 'name': + 'foo_test', + 'swarming': { + 'dimensions': { + 'device_os': 'LMY41U', + 'device_os_type': 'user', + 'device_type': 'hammerhead', 'os': 'Android' }, } }] }, - "Fake Android K Tester": { - "additional_compile_targets": ["bar_test"], - "gtest_tests": [{ - "test": - "foo_test", - "args": [ - "--gs-results-bucket=chromium-result-details", - "--recover-devices" + 'Fake Android K Tester': { + 'additional_compile_targets': ['bar_test'], + 'gtest_tests': [{ + 'test': + 'foo_test', + 'args': [ + '--gs-results-bucket=chromium-result-details', + '--recover-devices' ], - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" + 'merge': { + 'script': '//testing/merge_scripts/standard_gtest_merge.py' }, - "name": - "foo_test", - "swarming": { - "dimensions": { - "device_os": "KTU84P", - "device_os_type": "userdebug", - "device_type": "hammerhead", - "os": "Android", + 'name': + 'foo_test', + 'swarming': { + 'dimensions': { + 'device_os': 'KTU84P', + 'device_os_type': 'userdebug', + 'device_type': 'hammerhead', + 'os': 'Android', }, } }] }, - "Android Builder": { - "additional_compile_targets": ["bar_test"] + 'Android Builder': { + 'additional_compile_targets': ['bar_test'] } } TEST_QUERY_BOTS_TESTS_OUTPUT = { - "Fake Android M Tester": [{ - "name": "foo_test", - "test": "foo_test", + 'Fake Android M Tester': [{ + 'name': 'foo_test', + 'test': 'foo_test', }], - "Fake Android L Tester": [{ - "test": - "foo_test", - "args": - ["--gs-results-bucket=chromium-result-details", "--recover-devices"], - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" + 'Fake Android L Tester': [{ + 'test': + 'foo_test', + 'args': + ['--gs-results-bucket=chromium-result-details', '--recover-devices'], + 'merge': { + 'script': '//testing/merge_scripts/standard_gtest_merge.py' }, - "name": - "foo_test", - "swarming": { - "dimensions": { - "device_os": "LMY41U", - "device_os_type": "user", - "device_type": "hammerhead", - "os": "Android" + 'name': + 'foo_test', + 'swarming': { + 'dimensions': { + 'device_os': 'LMY41U', + 'device_os_type': 'user', + 'device_type': 'hammerhead', + 'os': 'Android' }, } }], - "Android Builder": [], - "Fake Android K Tester": [{ - "test": - "foo_test", - "args": - ["--gs-results-bucket=chromium-result-details", "--recover-devices"], - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" + 'Android Builder': [], + 'Fake Android K Tester': [{ + 'test': + 'foo_test', + 'args': + ['--gs-results-bucket=chromium-result-details', '--recover-devices'], + 'merge': { + 'script': '//testing/merge_scripts/standard_gtest_merge.py' }, - "name": - "foo_test", - "swarming": { - "dimensions": { - "device_os": "KTU84P", - "device_os_type": "userdebug", - "device_type": "hammerhead", - "os": "Android" + 'name': + 'foo_test', + 'swarming': { + 'dimensions': { + 'device_os': 'KTU84P', + 'device_os_type': 'userdebug', + 'device_type': 'hammerhead', + 'os': 'Android' }, } }] } TEST_QUERY_BOT_OUTPUT = { - "additional_compile_targets": ["bar_test"], - "gtest_tests": [ + 'additional_compile_targets': ['bar_test'], + 'gtest_tests': [ { - "test": - "foo_test", - "args": [ - "--gs-results-bucket=chromium-result-details", - "--recover-devices", + 'test': + 'foo_test', + 'args': [ + '--gs-results-bucket=chromium-result-details', + '--recover-devices', ], - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py", + 'merge': { + 'script': '//testing/merge_scripts/standard_gtest_merge.py', }, - "name": - "foo_test", - "swarming": { - "dimensions": { - "device_os": "KTU84P", - "device_os_type": "userdebug", - "device_type": "hammerhead", - "os": "Android", + 'name': + 'foo_test', + 'swarming': { + 'dimensions': { + 'device_os': 'KTU84P', + 'device_os_type': 'userdebug', + 'device_type': 'hammerhead', + 'os': 'Android', }, }, }, ], } TEST_QUERY_BOT_TESTS_OUTPUT = [{ - "test": - "foo_test", - "args": - ["--gs-results-bucket=chromium-result-details", "--recover-devices"], - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" + 'test': + 'foo_test', + 'args': + ['--gs-results-bucket=chromium-result-details', '--recover-devices'], + 'merge': { + 'script': '//testing/merge_scripts/standard_gtest_merge.py' }, - "name": - "foo_test", - "swarming": { - "dimensions": { - "device_os": "LMY41U", - "device_os_type": "user", - "device_type": "hammerhead", - "os": "Android" + 'name': + 'foo_test', + 'swarming': { + 'dimensions': { + 'device_os': 'LMY41U', + 'device_os_type': 'user', + 'device_type': 'hammerhead', + 'os': 'Android' }, } }] TEST_QUERY_TESTS_OUTPUT = { - "bar_test": { + 'bar_test': { 'name': 'bar_test', 'swarming': { 'dimensions': { @@ -3198,7 +3198,7 @@ }, } }, - "foo_test": { + 'foo_test': { 'name': 'foo_test', 'swarming': { 'dimensions': { @@ -3208,11 +3208,11 @@ } } -TEST_QUERY_TESTS_MULTIPLE_PARAMS_OUTPUT = ["foo_test"] +TEST_QUERY_TESTS_MULTIPLE_PARAMS_OUTPUT = ['foo_test'] -TEST_QUERY_TESTS_DIMENSION_PARAMS_OUTPUT = ["bar_test"] +TEST_QUERY_TESTS_DIMENSION_PARAMS_OUTPUT = ['bar_test'] -TEST_QUERY_TESTS_SWARMING_PARAMS_OUTPUT = ["bar_test_test"] +TEST_QUERY_TESTS_SWARMING_PARAMS_OUTPUT = ['bar_test_test'] TEST_QUERY_TESTS_PARAMS_OUTPUT = ['bar_test_test'] @@ -3228,9 +3228,9 @@ } TEST_QUERY_TEST_BOTS_OUTPUT = [ - "Fake Android K Tester", - "Fake Android L Tester", - "Fake Android M Tester", + 'Fake Android K Tester', + 'Fake Android L Tester', + 'Fake Android M Tester', ] TEST_QUERY_TEST_BOTS_ISOLATED_SCRIPTS_OUTPUT = ['Fake Tester'] @@ -3248,7 +3248,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_BOTS_OUTPUT) def test_query_bots_invalid(self): @@ -3281,7 +3281,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_BOTS_TESTS_OUTPUT) def test_query_invalid_bots_tests(self): @@ -3304,7 +3304,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.maxDiff = None # pragma pylint: disable=attribute-defined-outside-init self.assertEqual(query_json, TEST_QUERY_BOT_OUTPUT) @@ -3352,7 +3352,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_BOT_TESTS_OUTPUT) def test_query_tests(self): @@ -3363,7 +3363,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TESTS_OUTPUT) def test_query_tests_invalid(self): @@ -3386,7 +3386,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TESTS_MULTIPLE_PARAMS_OUTPUT) def test_query_tests_invalid_params(self): @@ -3409,7 +3409,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TESTS_DIMENSION_PARAMS_OUTPUT) def test_query_tests_swarming_params(self): @@ -3420,7 +3420,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TESTS_SWARMING_PARAMS_OUTPUT) def test_query_tests_params(self): @@ -3431,7 +3431,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TESTS_PARAMS_OUTPUT) def test_query_tests_params_false(self): @@ -3442,7 +3442,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TESTS_PARAMS_FALSE_OUTPUT) def test_query_test(self): @@ -3453,7 +3453,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TEST_OUTPUT) def test_query_test_invalid_id(self): @@ -3488,7 +3488,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TEST_BOTS_OUTPUT) def test_query_test_bots_isolated_scripts(self): @@ -3499,7 +3499,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TEST_BOTS_ISOLATED_SCRIPTS_OUTPUT) def test_query_test_bots_invalid(self): @@ -3522,7 +3522,7 @@ LUCI_MILO_CFG, mixins=SWARMING_MIXINS_SORTED) fbb.query(fbb.args) - query_json = json.loads("".join(fbb.printed_lines)) + query_json = json.loads(''.join(fbb.printed_lines)) self.assertEqual(query_json, TEST_QUERY_TEST_BOTS_NO_BOTS_OUTPUT) def test_query_invalid(self):
diff --git a/testing/buildbot/query_optimal_shard_counts.py b/testing/buildbot/query_optimal_shard_counts.py index e3e6bd0..c5aa16e 100755 --- a/testing/buildbot/query_optimal_shard_counts.py +++ b/testing/buildbot/query_optimal_shard_counts.py
@@ -78,8 +78,8 @@ lookback_end_date=lookback_end_date, ) return _run_query([ - "bq", "query", "--project_id=" + _CLOUD_PROJECT_ID, "--format=json", - "--max_rows=100000", "--nouse_legacy_sql", query + 'bq', 'query', '--project_id=' + _CLOUD_PROJECT_ID, '--format=json', + '--max_rows=100000', '--nouse_legacy_sql', query ]) @@ -94,8 +94,8 @@ percentile=percentile, ) return _run_query([ - "bq", "query", "--project_id=" + _CLOUD_PROJECT_ID, "--format=json", - "--max_rows=100000", "--nouse_legacy_sql", query + 'bq', 'query', '--project_id=' + _CLOUD_PROJECT_ID, '--format=json', + '--max_rows=100000', '--nouse_legacy_sql', query ]) @@ -109,8 +109,8 @@ lookback_end_date=lookback_end_date, ) return _run_query([ - "bq", "query", "--project_id=" + _CLOUD_PROJECT_ID, "--format=json", - "--max_rows=100000", "--nouse_legacy_sql", query + 'bq', 'query', '--project_id=' + _CLOUD_PROJECT_ID, '--format=json', + '--max_rows=100000', '--nouse_legacy_sql', query ])
diff --git a/testing/buildbot/scripts/upload_test_result_artifacts.py b/testing/buildbot/scripts/upload_test_result_artifacts.py index e033f73..8fb26cb 100755 --- a/testing/buildbot/scripts/upload_test_result_artifacts.py +++ b/testing/buildbot/scripts/upload_test_result_artifacts.py
@@ -75,7 +75,7 @@ file a bug with crbug.com/new and cc martiniss@. """ if not isinstance(test_trie, dict): - raise ValueError("expected %s to be a dict" % test_trie) + raise ValueError('expected %s to be a dict' % test_trie) tests = {}
diff --git a/testing/clusterfuzz/common/fuzzy_types.py b/testing/clusterfuzz/common/fuzzy_types.py index b29ec73..0961d5e 100644 --- a/testing/clusterfuzz/common/fuzzy_types.py +++ b/testing/clusterfuzz/common/fuzzy_types.py
@@ -51,23 +51,23 @@ # If we're still here, apply a more generic mutation mutations = [ - lambda _: "".join( + lambda _: ''.join( random.choice(string.printable) for _ in range(utils.UniformExpoInteger(0, 14))), # We let through the surrogate. The decode exception is handled at caller. - lambda _: "".join( + lambda _: ''.join( chr(random.randint(0, sys.maxunicode)) for _ in range(utils.UniformExpoInteger(0, 14))).encode( 'utf-8', 'surrogatepass'), lambda _: os.urandom(utils.UniformExpoInteger(0, 14)), lambda s: s * utils.UniformExpoInteger(1, 5), - lambda s: s + "A" * utils.UniformExpoInteger(0, 14), - lambda s: "A" * utils.UniformExpoInteger(0, 14) + s, + lambda s: s + 'A' * utils.UniformExpoInteger(0, 14), + lambda s: 'A' * utils.UniformExpoInteger(0, 14) + s, lambda s: s[:-random.randint(1, max(1, len(s) - 1))], lambda s: textwrap.fill(s, random.randint(1, max(1, len(s) - 1))), - lambda _: "", + lambda _: '', ] return random.choice(mutations)(s) @@ -80,12 +80,12 @@ if random.getrandbits(1): # Flip a coin to decide whether to fuzz return val if not random.getrandbits(4): # Delete the integer 1/16th of the time - return "" + return '' decimal = val.isdigit() # Assume decimal digits means a decimal number n = FuzzyInt(int(val) if decimal else int(val, 16)) - return str(n) if decimal else "%x" % n + return str(n) if decimal else '%x' % n - return re.sub(r"\b[a-fA-F]*\d[0-9a-fA-F]*\b", ReplaceInt, s) + return re.sub(r'\b[a-fA-F]*\d[0-9a-fA-F]*\b', ReplaceInt, s) def FuzzBase64InString(s): @@ -98,12 +98,12 @@ # This only matches obvious Base64 words with trailing equals signs return re.sub( - r"(?<![A-Za-z0-9+/])" - r"(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)" - r"(?![A-Za-z0-9+/])", ReplaceBase64, s) + r'(?<![A-Za-z0-9+/])' + r'(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)' + r'(?![A-Za-z0-9+/])', ReplaceBase64, s) -def FuzzListInString(s, separators=r", |,|; |;|\r\n|\s"): +def FuzzListInString(s, separators=r', |,|; |;|\r\n|\s'): """Tries to interpret the string as a list, and fuzzes it if successful.""" seps = re.findall(separators, s) if not seps: @@ -135,7 +135,7 @@ location = random.randint(0, max(0, len(self) - 1)) if amount is None: amount = utils.RandomLowInteger(min(1, len(self)), len(self) - location) - if hasattr(value, "__call__"): + if hasattr(value, '__call__'): new_elements = (value() for i in range(amount)) else: new_elements = itertools.repeat(value, amount) @@ -151,7 +151,7 @@ location = random.randint(0, max(0, len(self) - 1)) if amount is None: amount = utils.UniformExpoInteger(0, max_exponent) - if hasattr(value, "__call__"): + if hasattr(value, '__call__'): new_elements = (value() for i in range(amount)) else: new_elements = itertools.repeat(value, amount) @@ -172,7 +172,7 @@ class FuzzyList(list, FuzzySequence): """A list with additional methods for fuzzing.""" - def RandomMutation(self, count=None, new_element=""): + def RandomMutation(self, count=None, new_element=''): """Apply count random mutations chosen from a list.""" random_items = lambda: random.choice(self) if self else new_element mutations = [ @@ -194,7 +194,7 @@ """A bytearray with additional methods for mutating the sequence of bytes.""" def __repr__(self): - return "%s(%r)" % (self.__class__.__name__, str(self)) + return '%s(%r)' % (self.__class__.__name__, str(self)) def FlipBits(self, num_bits=None): """Flip num_bits bits in the buffer at random."""
diff --git a/testing/flake_suppressor_common/argument_parsing.py b/testing/flake_suppressor_common/argument_parsing.py index 723e458..c43f78e 100644 --- a/testing/flake_suppressor_common/argument_parsing.py +++ b/testing/flake_suppressor_common/argument_parsing.py
@@ -103,9 +103,9 @@ 'when all other build-fail* thresholds meet.')) parser.add_argument('--builder-name', default=[], - action="append", - dest="builder_names", - help="CI builder list to suppress tests.") + action='append', + dest='builder_names', + help='CI builder list to suppress tests.') args = parser.parse_args() if not args.prompt_for_user_input:
diff --git a/testing/flake_suppressor_common/common_typing.py b/testing/flake_suppressor_common/common_typing.py index 8f1cf02..792ea137 100644 --- a/testing/flake_suppressor_common/common_typing.py +++ b/testing/flake_suppressor_common/common_typing.py
@@ -58,6 +58,6 @@ class ResultStatus(str, Enum): - ABORT = "ABORT" - CRASH = "CRASH" - FAIL = "FAIL" + ABORT = 'ABORT' + CRASH = 'CRASH' + FAIL = 'FAIL'
diff --git a/testing/libfuzzer/archive_corpus.py b/testing/libfuzzer/archive_corpus.py index 538c26e..9796b75 100755 --- a/testing/libfuzzer/archive_corpus.py +++ b/testing/libfuzzer/archive_corpus.py
@@ -19,7 +19,7 @@ def main(): - parser = argparse.ArgumentParser(description="Generate fuzzer config.") + parser = argparse.ArgumentParser(description='Generate fuzzer config.') parser.add_argument('corpus_directories', metavar='corpus_dir', type=str, @@ -44,7 +44,7 @@ with zipfile.ZipFile(seed_corpus_path, 'w') as z: # Turn warnings into errors to interrupt the build: crbug.com/653920. with warnings.catch_warnings(): - warnings.simplefilter("error") + warnings.simplefilter('error') for i, corpus_file in enumerate(corpus_files): # To avoid duplication of filenames inside the archive, use numbers. arcname = '%016d' % i
diff --git a/testing/libfuzzer/dictionary_generator.py b/testing/libfuzzer/dictionary_generator.py index fe538f6..8cdaec3 100755 --- a/testing/libfuzzer/dictionary_generator.py +++ b/testing/libfuzzer/dictionary_generator.py
@@ -34,7 +34,7 @@ """Escape all unprintable and control characters in an element.""" element_escaped = element.encode('string_escape') # Remove escaping for single quote because it breaks libFuzzer. - element_escaped = element_escaped.replace('\\\'', '\'') + element_escaped = element_escaped.replace("\\'", "'") # Add escaping for double quote. element_escaped = element_escaped.replace('"', '\\"') return element_escaped @@ -119,7 +119,7 @@ """Generate a dictionary for given pair of fuzzer binary and specification.""" for filepath in [path_to_binary, path_to_spec]: if not os.path.exists(filepath): - logging.error('%s doesn\'t exist. Exit.', filepath) + logging.error("%s doesn't exist. Exit.", filepath) sys.exit(1) words_from_binary = ExtractWordsFromBinary(path_to_binary) @@ -205,7 +205,7 @@ def main(): - parser = argparse.ArgumentParser(description="Generate fuzzer dictionary.") + parser = argparse.ArgumentParser(description='Generate fuzzer dictionary.') parser.add_argument('--fuzzer', required=True, help='Path to a fuzzer binary executable. It is '
diff --git a/testing/libfuzzer/fuzzers/generate_javascript_parser_proto.py b/testing/libfuzzer/fuzzers/generate_javascript_parser_proto.py index 7a18421..b0b6103 100755 --- a/testing/libfuzzer/fuzzers/generate_javascript_parser_proto.py +++ b/testing/libfuzzer/fuzzers/generate_javascript_parser_proto.py
@@ -140,5 +140,5 @@ f.write(conversion_contents) -if __name__ == "__main__": +if __name__ == '__main__': main(sys.argv)
diff --git a/testing/libfuzzer/fuzzers/generate_v8_inspector_fuzzer_corpus.py b/testing/libfuzzer/fuzzers/generate_v8_inspector_fuzzer_corpus.py index 233f8c80..3f6220a 100755 --- a/testing/libfuzzer/fuzzers/generate_v8_inspector_fuzzer_corpus.py +++ b/testing/libfuzzer/fuzzers/generate_v8_inspector_fuzzer_corpus.py
@@ -22,9 +22,9 @@ def load_file(output_file, input_file, loaded_files, load_root): if input_file in loaded_files: - sys.exit('Recursive load of \'{}\''.format(input_file)) + sys.exit("Recursive load of '{}'".format(input_file)) loaded_files.add(input_file) - output_file.write('\n// Loaded from \'{}\':\n'.format(input_file)) + output_file.write("\n// Loaded from '{}':\n".format(input_file)) with open(os.path.join(load_root, input_file)) as file: resolve_loads(output_file, file.readlines(), loaded_files, load_root)
diff --git a/testing/libfuzzer/research/fuzzilli_idl_fuzzing/generator.py b/testing/libfuzzer/research/fuzzilli_idl_fuzzing/generator.py index 07f1691c..517341e 100755 --- a/testing/libfuzzer/research/fuzzilli_idl_fuzzing/generator.py +++ b/testing/libfuzzer/research/fuzzilli_idl_fuzzing/generator.py
@@ -94,7 +94,7 @@ values: List[SwiftExpression] def fuzzilli_repr(self) -> str: - values = ", ".join([v.fuzzilli_repr() for v in self.values]) + values = ', '.join([v.fuzzilli_repr() for v in self.values]) return f'[{values}]' @@ -265,17 +265,17 @@ 'ArrayBufferView': ILType.jsDataView(), 'SharedArray': ILType.jsSharedArrayBuffer(), 'Int8Array': ILType.jsTypedArray('Uint8Array'), - 'Int16Array': ILType.jsTypedArray("Int16Array"), - 'Int32Array': ILType.jsTypedArray("Int32Array"), - 'Uint8Array': ILType.jsTypedArray("Uint8Array"), - 'Uint16Array': ILType.jsTypedArray("Uint16Array"), - 'Uint32Array': ILType.jsTypedArray("Uint32Array"), - 'Uint8ClampedArray': ILType.jsTypedArray("Uint8ClampedArray"), - 'BigInt64Array': ILType.jsTypedArray("BigInt64Array"), - 'BigUint64Array': ILType.jsTypedArray("BigUint64Array"), - 'Float16Array': ILType.jsTypedArray("Float16Array"), - 'Float32Array': ILType.jsTypedArray("Float32Array"), - 'Float64Array': ILType.jsTypedArray("Float64Array"), + 'Int16Array': ILType.jsTypedArray('Int16Array'), + 'Int32Array': ILType.jsTypedArray('Int32Array'), + 'Uint8Array': ILType.jsTypedArray('Uint8Array'), + 'Uint16Array': ILType.jsTypedArray('Uint16Array'), + 'Uint32Array': ILType.jsTypedArray('Uint32Array'), + 'Uint8ClampedArray': ILType.jsTypedArray('Uint8ClampedArray'), + 'BigInt64Array': ILType.jsTypedArray('BigInt64Array'), + 'BigUint64Array': ILType.jsTypedArray('BigUint64Array'), + 'Float16Array': ILType.jsTypedArray('Float16Array'), + 'Float32Array': ILType.jsTypedArray('Float32Array'), + 'Float64Array': ILType.jsTypedArray('Float64Array'), 'DataView': ILType.jsDataView(), } @@ -521,11 +521,11 @@ parser.add_argument('-p', '--path', required=True, - help="Path to the web_idl_database.") + help='Path to the web_idl_database.') parser.add_argument('-o', '--outfile', required=True, - help="Path to the output profile.") + help='Path to the output profile.') args = parser.parse_args() database = web_idl.Database.read_from_file(args.path) @@ -545,5 +545,5 @@ f.write(template.render(context)) -if __name__ == "__main__": +if __name__ == '__main__': main()
diff --git a/testing/libfuzzer/zip_sources.py b/testing/libfuzzer/zip_sources.py index 5c9eb66..f139ef8 100755 --- a/testing/libfuzzer/zip_sources.py +++ b/testing/libfuzzer/zip_sources.py
@@ -21,7 +21,7 @@ def main(): - parser = argparse.ArgumentParser(description="Zip binary sources.") + parser = argparse.ArgumentParser(description='Zip binary sources.') parser.add_argument('--binary', required=True, help='binary file to read') parser.add_argument('--workdir', required=True,
diff --git a/testing/merge_scripts/code_coverage/convert_to_istanbul_test.py b/testing/merge_scripts/code_coverage/convert_to_istanbul_test.py index 5b19325..87d899d 100755 --- a/testing/merge_scripts/code_coverage/convert_to_istanbul_test.py +++ b/testing/merge_scripts/code_coverage/convert_to_istanbul_test.py
@@ -33,16 +33,16 @@ subtract(5, 2); """ _INVALID_MAPPING_A = ( - "//# sourceMappingURL=data:application/json;base64," - "eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvby50cyJdLCJuYW1lcyI6W10sIm1hcHBpb" - "mdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Oz" - "s7OztBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUN" - "BIiwiZmlsZSI6Ii91c3IvbG9jYWwvZ29vZ2xlL2hvbWUvc3Jpbml2YXNoZWdkZS9jaHJv" - "bWl1bS9zcmMvZm9vX3ByZS50cyIsInNvdXJjZVJvb3QiOiIvdXNyL2xvY2FsL2dvb2dsZ" - "S9ob21lL3NyaW5pdmFzaGVnZGUvY2hyb21pdW0vc3JjIiwic291cmNlc0NvbnRlbnQiOl" - "siZnVuY3Rpb24gYWRkKGEsIGIpIHtcbiAgcmV0dXJuIGEgKyBiO1xufVxuXG5mdW5jdGl" - "vbiBzdWJ0cmFjdChhLCBiKSB7XG4gIHJldHVybiBhIC0gYjtcbn1cblxuc3VidHJhY3Qo" - "NSwgMik7XG4iXX0=") + '//# sourceMappingURL=data:application/json;base64,' + 'eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvby50cyJdLCJuYW1lcyI6W10sIm1hcHBpb' + 'mdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Oz' + 's7OztBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUN' + 'BIiwiZmlsZSI6Ii91c3IvbG9jYWwvZ29vZ2xlL2hvbWUvc3Jpbml2YXNoZWdkZS9jaHJv' + 'bWl1bS9zcmMvZm9vX3ByZS50cyIsInNvdXJjZVJvb3QiOiIvdXNyL2xvY2FsL2dvb2dsZ' + 'S9ob21lL3NyaW5pdmFzaGVnZGUvY2hyb21pdW0vc3JjIiwic291cmNlc0NvbnRlbnQiOl' + 'siZnVuY3Rpb24gYWRkKGEsIGIpIHtcbiAgcmV0dXJuIGEgKyBiO1xufVxuXG5mdW5jdGl' + 'vbiBzdWJ0cmFjdChhLCBiKSB7XG4gIHJldHVybiBhIC0gYjtcbn1cblxuc3VidHJhY3Qo' + 'NSwgMik7XG4iXX0=') _TEST_COVERAGE_A = """{ "result": [ @@ -320,11 +320,11 @@ output_file = os.path.join(out_dir, output_file_name) node.RunNode([ str(_SOURCE_MAP_PROCESSOR), - "--originals={}".format(" ".join([original_file])), - "--inputs={}".format(" ".join([input_file])), - "--outputs={}".format(" ".join([output_file])), - "--inline-sourcemaps", - "--sourceRoot={}".format(self.sourceRoot), + '--originals={}'.format(' '.join([original_file])), + '--inputs={}'.format(' '.join([input_file])), + '--outputs={}'.format(' '.join([output_file])), + '--inline-sourcemaps', + '--sourceRoot={}'.format(self.sourceRoot), ]) def write_sources(self, *file_path_contents): @@ -435,7 +435,7 @@ def test_original_source_missing(self): self.write_sources((('//file.js', 'file.js'), self._TEST_SOURCE_A)) self.write_coverages(('test_coverage.cov.json', self._TEST_COVERAGE_A)) - os.remove(os.path.join(self.source_dir, "file.js")) + os.remove(os.path.join(self.source_dir, 'file.js')) merger.convert_raw_coverage_to_istanbul([self.coverage_dir], self.out_dir, self.task_output_dir)
diff --git a/testing/merge_scripts/code_coverage/merge_js_lib_test.py b/testing/merge_scripts/code_coverage/merge_js_lib_test.py index 1983584..46efbc12 100755 --- a/testing/merge_scripts/code_coverage/merge_js_lib_test.py +++ b/testing/merge_scripts/code_coverage/merge_js_lib_test.py
@@ -51,13 +51,13 @@ for i, test_script in enumerate(test_files): file_path = os.path.join(scripts_dir, '%d.js.json' % i) - source_map = "" + source_map = '' if test_script['exists']: # Create an inline sourcemap with just the required keys. source_map_data_url = base64.b64encode( json.dumps({ - "sources": [os.path.join(*test_script['location'])], - "sourceRoot": "" + 'sources': [os.path.join(*test_script['location'])], + 'sourceRoot': '' }).encode('utf-8')) source_map = 'data:application/json;base64,' + \ @@ -302,8 +302,8 @@ }""" expected_after_remap = { - "chrome/browser/fileA.js": { - "path": "chrome/browser/fileA.js" + 'chrome/browser/fileA.js': { + 'path': 'chrome/browser/fileA.js' } } @@ -315,8 +315,8 @@ with open(coverage_file_path, 'w', encoding='utf-8', newline='') as f: f.write(test_file_data) - merger.remap_paths_to_relative(coverage_file_path, "/path/to/checkout", - "/path/to/checkout/out/dir") + merger.remap_paths_to_relative(coverage_file_path, '/path/to/checkout', + '/path/to/checkout/out/dir') with open(coverage_file_path, 'rb') as f: coverage_json = json.load(f)
diff --git a/testing/merge_scripts/code_coverage/merge_lib.py b/testing/merge_scripts/code_coverage/merge_lib.py index 0234ccd..e2f04e8 100644 --- a/testing/merge_scripts/code_coverage/merge_lib.py +++ b/testing/merge_scripts/code_coverage/merge_lib.py
@@ -47,7 +47,7 @@ input_file = os.path.join(output_dir, 'input-profdata-files.txt').replace('\\', '/') with open(input_file, 'w') as fd: - logging.info("List of .profdata files...") + logging.info('List of .profdata files...') for file_path in profile_input_file_paths: logging.info(file_path) fd.write('%s\n' % file_path)
diff --git a/testing/merge_scripts/code_coverage/merge_results.py b/testing/merge_scripts/code_coverage/merge_results.py index 3ce9118b..9fd1e93c 100755 --- a/testing/merge_scripts/code_coverage/merge_results.py +++ b/testing/merge_scripts/code_coverage/merge_results.py
@@ -83,7 +83,7 @@ def main(): - desc = "Merge profraw files in <--task-output-dir> into a single profdata." + desc = 'Merge profraw files in <--task-output-dir> into a single profdata.' parser = _MergeAPIArgumentParser(description=desc) params = parser.parse_args() @@ -180,7 +180,7 @@ logging.warning('Additional merge script %s exited with %s', params.additional_merge_script, rc) elif len(params.jsons_to_merge) == 1: - logging.info("Only one output needs to be merged; directly copying it.") + logging.info('Only one output needs to be merged; directly copying it.') with open(params.jsons_to_merge[0]) as f_read: with open(params.output_json, 'w') as f_write: f_write.write(f_read.read())
diff --git a/testing/merge_scripts/code_coverage/merge_steps.py b/testing/merge_scripts/code_coverage/merge_steps.py index a23f79c..2525b74a 100755 --- a/testing/merge_scripts/code_coverage/merge_steps.py +++ b/testing/merge_scripts/code_coverage/merge_steps.py
@@ -37,7 +37,7 @@ def main(): - desc = "Merge profdata files in <--input-dir> into a single profdata." + desc = 'Merge profdata files in <--input-dir> into a single profdata.' parser = _merge_steps_argument_parser(description=desc) params = parser.parse_args()
diff --git a/testing/merge_scripts/results_merger.py b/testing/merge_scripts/results_merger.py index 5085154..bf7e9566 100755 --- a/testing/merge_scripts/results_merger.py +++ b/testing/merge_scripts/results_merger.py
@@ -195,9 +195,9 @@ if k in dest_node: if not isinstance(v, dict): raise MergeException( - "%s:%s: %r not mergable, curr_node: %r\ndest_node: %r" % + '%s:%s: %r not mergable, curr_node: %r\ndest_node: %r' % (prefix, k, v, curr_node, dest_node)) - pending_nodes.append(("%s:%s" % (prefix, k), dest_node[k], v)) + pending_nodes.append(('%s:%s' % (prefix, k), dest_node[k], v)) else: dest_node[k] = v return dest @@ -248,7 +248,7 @@ try: dest[key] = merge_func(source[key], dest[key]) except MergeException as e: - message = "MergeFailure for %s\n%s" % (key, e.args[0]) + message = 'MergeFailure for %s\n%s' % (key, e.args[0]) e.args = (message, ) + e.args[1:] raise del source[key] @@ -256,7 +256,7 @@ def main(files): if len(files) < 2: - sys.stderr.write("Not enough JSON files to merge.\n") + sys.stderr.write('Not enough JSON files to merge.\n') return 1 sys.stderr.write('Starting with %s\n' % files[0]) result = json.load(open(files[0])) @@ -267,5 +267,5 @@ return 0 -if __name__ == "__main__": +if __name__ == '__main__': sys.exit(main(sys.argv[1:]))
diff --git a/testing/merge_scripts/results_merger_test.py b/testing/merge_scripts/results_merger_test.py index 51f7b56..75ab2af5 100755 --- a/testing/merge_scripts/results_merger_test.py +++ b/testing/merge_scripts/results_merger_test.py
@@ -169,7 +169,7 @@ }})) def test_merge_tries_unmergable(self): - with six.assertRaisesRegex(self, results_merger.MergeException, "a:b"): + with six.assertRaisesRegex(self, results_merger.MergeException, 'a:b'): results_merger.merge_tries({'a': {'b': 'A'}}, {'a': {'b': 'C'}}) def test_merge_metadata(self):
diff --git a/testing/merge_scripts/standard_gtest_merge.py b/testing/merge_scripts/standard_gtest_merge.py index 33e9a97e..77fadd6 100755 --- a/testing/merge_scripts/standard_gtest_merge.py +++ b/testing/merge_scripts/standard_gtest_merge.py
@@ -40,7 +40,7 @@ # summary.json is produced by swarming client itself. We are mostly interested # in the number of shards. try: - with open(summary_json, encoding="utf-8") as f: + with open(summary_json, encoding='utf-8') as f: summary = json.load(f) except (IOError, ValueError): emit_warning( @@ -70,11 +70,11 @@ if state == u'BOT_DIED': emit_warning('Shard #%d had a Swarming internal failure' % index) elif state == u'EXPIRED': - emit_warning('There wasn\'t enough capacity to run your test') + emit_warning("There wasn't enough capacity to run your test") elif state == u'TIMED_OUT': emit_warning( 'Test runtime exceeded allocated time', - 'Either it ran for too long (hard timeout) or it didn\'t produce ' + "Either it ran for too long (hard timeout) or it didn't produce " 'I/O for an extended period of time (I/O timeout)') elif state != u'COMPLETED': emit_warning('Invalid Swarming task state: %s' % state) @@ -154,7 +154,7 @@ file=sys.stderr) return (None, 'shard %s test output exceeded the size limit' % index) - with open(path, encoding="utf-8") as f: + with open(path, encoding='utf-8') as f: return (json.load(f), None) except (IOError, ValueError, OSError) as e: print('Missing or invalid gtest JSON file: %s' % path, file=sys.stderr) @@ -178,7 +178,7 @@ def standard_gtest_merge(output_json, summary_json, jsons_to_merge): output = merge_shard_results(summary_json, jsons_to_merge) - with open(output_json, 'w', encoding="utf-8") as f: + with open(output_json, 'w', encoding='utf-8') as f: json.dump(output, f) return 0
diff --git a/testing/merge_scripts/standard_gtest_merge_test.py b/testing/merge_scripts/standard_gtest_merge_test.py index 3f1bd5f..c2e2466 100755 --- a/testing/merge_scripts/standard_gtest_merge_test.py +++ b/testing/merge_scripts/standard_gtest_merge_test.py
@@ -567,7 +567,7 @@ old_json_limit = standard_gtest_merge.OUTPUT_JSON_SIZE_LIMIT len0 = len(json.dumps(GOOD_GTEST_JSON_0)) len1 = len(json.dumps(GOOD_GTEST_JSON_1)) - large_shard = "0" if len0 > len1 else "1" + large_shard = '0' if len0 > len1 else '1' try: # Override max output.json size just for this test. standard_gtest_merge.OUTPUT_JSON_SIZE_LIMIT = min(len0, len1)
diff --git a/testing/pylintrc b/testing/pylintrc index ae028b0..62ace1dcb 100644 --- a/testing/pylintrc +++ b/testing/pylintrc
@@ -28,7 +28,6 @@ fixme, import-error, invalid-name, - invalid-string-quote, invalid-triple-quote, locally-disabled, locally-enabled,
diff --git a/testing/run_pytype.py b/testing/run_pytype.py index 231114c8..0f20545 100755 --- a/testing/run_pytype.py +++ b/testing/run_pytype.py
@@ -29,7 +29,7 @@ ] TEST_NAME = 'testing_pytype' -TEST_LOCATION = "//testing/run_pytype.py" +TEST_LOCATION = '//testing/run_pytype.py' def main() -> int:
diff --git a/testing/scripts/check_static_initializers.py b/testing/scripts/check_static_initializers.py index edc09af..d022d44 100755 --- a/testing/scripts/check_static_initializers.py +++ b/testing/scripts/check_static_initializers.py
@@ -147,7 +147,7 @@ # Get the basename and remove line number suffix. basename = os.path.basename(e['filename']).split(':')[0] symbol = e['symbol_name'] - descriptor = f"{basename} : {symbol}" + descriptor = f'{basename} : {symbol}' if not any(re.match(p, descriptor) for p in allowlist[binary_name]): ret = 1 print(('Error: file "%s" is not expected to have static initializers in' @@ -190,7 +190,7 @@ # TODO(crbug.com/40285648): Delete this assert if it's not seen to fail # anywhere. assert not check_if_chromeos(args), ( - "This script is no longer supported for CrOS") + 'This script is no longer supported for CrOS') rc = main_linux(src_dir) else: sys.stderr.write('Unsupported platform %s.\n' % repr(sys.platform))
diff --git a/testing/scripts/checkbins.py b/testing/scripts/checkbins.py index 9efe336..7030845 100755 --- a/testing/scripts/checkbins.py +++ b/testing/scripts/checkbins.py
@@ -35,7 +35,7 @@ for maybe_py3 in WIN_PY3_TARGETS: if os.path.exists(os.path.join(d, maybe_py3)): return os.path.join(d, maybe_py3) - raise Exception("Cannot find python3 to launch checkbins.py") + raise Exception('Cannot find python3 to launch checkbins.py') def main_run(args):
diff --git a/testing/scripts/run_chromedriver_tests.py b/testing/scripts/run_chromedriver_tests.py index baeaf4e..0880ac8 100755 --- a/testing/scripts/run_chromedriver_tests.py +++ b/testing/scripts/run_chromedriver_tests.py
@@ -30,7 +30,7 @@ def generate_test_filter_args(self, test_filter_str): if any('--filter' in arg for arg in self.rest_args): self.parser.error( - 'can\'t have the test call filter with the' + "can't have the test call filter with the" '--isolated-script-test-filter argument to the wrapper script') return ['--filter', test_filter_str.replace('::', ':')]
diff --git a/testing/scripts/run_flatbuffers_unittests.py b/testing/scripts/run_flatbuffers_unittests.py index c2c23f8..32fc7616 100755 --- a/testing/scripts/run_flatbuffers_unittests.py +++ b/testing/scripts/run_flatbuffers_unittests.py
@@ -52,7 +52,7 @@ # a non positive number). with open(tempfile_path) as f: output = f.read() - if "ALL TESTS PASSED\n" not in output: + if 'ALL TESTS PASSED\n' not in output: failures = [output] if args.isolated_script_test_output:
diff --git a/testing/scripts/run_performance_tests_unittest.py b/testing/scripts/run_performance_tests_unittest.py index f4d39f95..259658e7 100644 --- a/testing/scripts/run_performance_tests_unittest.py +++ b/testing/scripts/run_performance_tests_unittest.py
@@ -18,7 +18,7 @@ # The path where the output of a wpt run was written. This is the file that # gets processed by BaseWptScriptAdapter. -OUTPUT_JSON_FILENAME = "out.json" +OUTPUT_JSON_FILENAME = 'out.json' class TelemetryCommandGeneratorTest(unittest.TestCase):
diff --git a/testing/scripts/run_variations_smoke_tests.py b/testing/scripts/run_variations_smoke_tests.py index 2de0c8dc..c91c7fa 100755 --- a/testing/scripts/run_variations_smoke_tests.py +++ b/testing/scripts/run_variations_smoke_tests.py
@@ -65,9 +65,9 @@ def _get_httpd(): """Returns a HTTPServer instance.""" - hostname = "localhost" + hostname = 'localhost' port = 8000 - directory = os.path.join(_THIS_DIR, _VARIATIONS_TEST_DATA, "http_server") + directory = os.path.join(_THIS_DIR, _VARIATIONS_TEST_DATA, 'http_server') httpd = None handler = partial(SimpleHTTPRequestHandler, directory=directory) httpd = http.server.HTTPServer((hostname, port), handler) @@ -159,7 +159,7 @@ #(crbug/158372) if OS == 'win': cmd = ('powershell -command "&{(Get-Item' - '\'' + path_chrome + '\').VersionInfo.ProductVersion}"') + "'" + path_chrome + '\').VersionInfo.ProductVersion}"') version = subprocess.run(cmd, check=True, capture_output=True).stdout.decode('utf-8') else: @@ -167,7 +167,7 @@ version = subprocess.run(cmd, check=True, capture_output=True).stdout.decode('utf-8') #only return the version number portion - version = version.strip().split(" ")[-1] + version = version.strip().split(' ')[-1] return packaging.version.parse(version) @@ -233,7 +233,7 @@ chrome_options.add_argument('log-file=' + log_file) chrome_options.add_argument('variations-test-seed-path=' + path_seed) #TODO(crbug.com/40230862): Remove this line. - chrome_options.add_argument("disable-field-trial-config") + chrome_options.add_argument('disable-field-trial-config') for arg in args: chrome_options.add_argument(arg) @@ -313,8 +313,8 @@ """ httpd = _get_httpd() thread = None - address = "http://{}:{}".format(httpd.server_name, httpd.server_port) - logging.info("%s is used as local http server.", address) + address = 'http://{}:{}'.format(httpd.server_name, httpd.server_port) + logging.info('%s is used as local http server.', address) thread = Thread(target=httpd.serve_forever) thread.setDaemon(True) thread.start()
diff --git a/testing/scripts/rust/exe_util_unittests.py b/testing/scripts/rust/exe_util_unittests.py index 9b16978..6ceeef5 100755 --- a/testing/scripts/rust/exe_util_unittests.py +++ b/testing/scripts/rust/exe_util_unittests.py
@@ -14,6 +14,6 @@ class ExeUtilTests(fake_filesystem_unittest.TestCase): def test_run_and_tee_output(self): # Test wrapping Python as it echos a '.' character back. - args = [sys.executable, '-c', 'print(\'.\')'] + args = [sys.executable, '-c', "print('.')"] output = exe_util.run_and_tee_output(args) self.assertEqual('.', output.strip())
diff --git a/testing/scripts/rust/generate_script.py b/testing/scripts/rust/generate_script.py index ec5fa95..f053133 100755 --- a/testing/scripts/rust/generate_script.py +++ b/testing/scripts/rust/generate_script.py
@@ -55,9 +55,9 @@ raise ValueError( f'Duplicate entry "{exe_name}" in {input_filepath}') if args.make_bat: - suffix = ".exe" + suffix = '.exe' else: - suffix = "" + suffix = '' exes.add(f'{exe_name}{suffix}') if not exes: raise ValueError(f'Unexpectedly empty file: {input_filepath}')
diff --git a/testing/scripts/rust/generate_script_unittests.py b/testing/scripts/rust/generate_script_unittests.py index c6277317..b6e2cb57 100755 --- a/testing/scripts/rust/generate_script_unittests.py +++ b/testing/scripts/rust/generate_script_unittests.py
@@ -38,8 +38,8 @@ mode='w', encoding='utf-8') as f: filepath = f.name - f.write("foo\n") - f.write("bar\n") + f.write('foo\n') + f.write('bar\n') try: args.rust_test_executables = filepath actual = _generate_script(args, @@ -49,7 +49,8 @@ expected = ''' #!/bin/bash -env vpython3 "$(dirname $0)/../../../testing/scripts/rust/rust_main_program.py" \\ +env vpython3 \ +"$(dirname $0)/../../../testing/scripts/rust/rust_main_program.py" \\ "--rust-test-executable=$(dirname $0)/../bar" \\ "--rust-test-executable=$(dirname $0)/../foo" \\ "$@" @@ -70,8 +71,8 @@ mode='w', encoding='utf-8') as f: filepath = f.name - f.write("foo\n") - f.write("bar\n") + f.write('foo\n') + f.write('bar\n') try: args.rust_test_executables = filepath actual = _generate_script(args,
diff --git a/testing/scripts/rust/rust_main_program.py b/testing/scripts/rust/rust_main_program.py index 69b8c87..8e51788 100644 --- a/testing/scripts/rust/rust_main_program.py +++ b/testing/scripts/rust/rust_main_program.py
@@ -17,17 +17,17 @@ def _format_test_name(test_executable_name, test_case_name): - assert "//" not in test_executable_name - assert "/" not in test_case_name - test_case_name = "/".join(test_case_name.split("::")) - return "{}//{}".format(test_executable_name, test_case_name) + assert '//' not in test_executable_name + assert '/' not in test_case_name + test_case_name = '/'.join(test_case_name.split('::')) + return '{}//{}'.format(test_executable_name, test_case_name) def _parse_test_name(test_name): - assert "//" in test_name - assert "::" not in test_name - test_executable_name, test_case_name = test_name.split("//", 1) - test_case_name = "::".join(test_case_name.split("/")) + assert '//' in test_name + assert '::' not in test_name + test_executable_name, test_case_name = test_name.split('//', 1) + test_case_name = '::'.join(test_case_name.split('/')) return test_executable_name, test_case_name @@ -53,7 +53,7 @@ continue else: raise ValueError( - "Unexpected format of a list of tests: {}".format(output)) + 'Unexpected format of a list of tests: {}'.format(output)) test_names = [ _format_test_name(test_executable_name, test_case_name) for test_case_name in test_case_names @@ -153,9 +153,9 @@ ] args.extend(list_of_tests_to_run) - print("Running tests from {}...".format(self._name_of_test_executable)) + print('Running tests from {}...'.format(self._name_of_test_executable)) output = exe_util.run_and_tee_output(args) - print("Running tests from {}... DONE.".format( + print('Running tests from {}... DONE.'.format( self._name_of_test_executable)) print()
diff --git a/testing/scripts/rust/rust_main_program_unittests.py b/testing/scripts/rust/rust_main_program_unittests.py index d529cd4..6db43a0 100755 --- a/testing/scripts/rust/rust_main_program_unittests.py +++ b/testing/scripts/rust/rust_main_program_unittests.py
@@ -57,7 +57,8 @@ running 1 test test test_hello ... ok -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; \ +finished in 0.00s """.strip() with self.assertRaises(ValueError): _scrape_test_list(test_input, 'test_exe_name') @@ -82,7 +83,8 @@ failures: test_foobar -test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s +test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; \ +0 filtered out; finished in 0.00s """.strip() list_of_expected_test_names = [ 'test_foo', 'test_bar', 'foo::test_in_mod', 'test_foobar' @@ -107,8 +109,8 @@ def test_get_exe_specific_tests(self): result = _get_exe_specific_tests( - "exe_name", - ["exe_name//foo1", "exe_name//foo2", "other_exe//foo3"]) + 'exe_name', + ['exe_name//foo1', 'exe_name//foo2', 'other_exe//foo3']) self.assertEqual(['foo1', 'foo2'], result) def test_executable_wrapper_basic_construction(self):
diff --git a/testing/scripts/rust/test_filtering.py b/testing/scripts/rust/test_filtering.py index b054e77..34bf7f3 100644 --- a/testing/scripts/rust/test_filtering.py +++ b/testing/scripts/rust/test_filtering.py
@@ -73,9 +73,9 @@ def __str__(self): result = self._filter_text if self._is_exclusion_filter: - result = "-" + result + result = '-' + result if self._is_prefix_match: - result += "*" + result += '*' return result
diff --git a/testing/scripts/test_traffic_annotation_auditor.py b/testing/scripts/test_traffic_annotation_auditor.py index eee32b8..4415a90 100755 --- a/testing/scripts/test_traffic_annotation_auditor.py +++ b/testing/scripts/test_traffic_annotation_auditor.py
@@ -18,19 +18,19 @@ import common WINDOWS_SHEET_CONFIG = { - "spreadsheet_id": "1TmBr9jnf1-hrjntiVBzT9EtkINGrtoBYFMWad2MBeaY", - "annotations_sheet_name": "Annotations", - "chrome_version_sheet_name": "Chrome Version", - "silent_change_columns": [], - "last_update_column_name": "Last Update", + 'spreadsheet_id': '1TmBr9jnf1-hrjntiVBzT9EtkINGrtoBYFMWad2MBeaY', + 'annotations_sheet_name': 'Annotations', + 'chrome_version_sheet_name': 'Chrome Version', + 'silent_change_columns': [], + 'last_update_column_name': 'Last Update', } CHROMEOS_SHEET_CONFIG = { - "spreadsheet_id": "1928goWKy6LVdF9Nl5nV1OD260YC10dHsdrnHEGdGsg8", - "annotations_sheet_name": "Annotations", - "chrome_version_sheet_name": "Chrome Version", - "silent_change_columns": [], - "last_update_column_name": "Last Update", + 'spreadsheet_id': '1928goWKy6LVdF9Nl5nV1OD260YC10dHsdrnHEGdGsg8', + 'annotations_sheet_name': 'Annotations', + 'chrome_version_sheet_name': 'Chrome Version', + 'silent_change_columns': [], + 'last_update_column_name': 'Last Update', } @@ -40,7 +40,7 @@ def is_chromeos(build_path): current_platform = get_current_platform_from_gn_args(build_path) - return current_platform == "chromeos" + return current_platform == 'chromeos' def get_sheet_config(build_path): @@ -52,17 +52,16 @@ def get_current_platform_from_gn_args(build_path): - if sys.platform.startswith("linux") and build_path is not None: + if sys.platform.startswith('linux') and build_path is not None: try: - with open(os.path.join(build_path, "args.gn")) as f: + with open(os.path.join(build_path, 'args.gn')) as f: gn_args = f.read() if not gn_args: - logging.info("Could not retrieve args.gn") + logging.info('Could not retrieve args.gn') - pattern = re.compile(r"^\s*target_os\s*=\s*\"chromeos\"\s*$", - re.MULTILINE) + pattern = re.compile(r'^\s*target_os\s*=\s*"chromeos"\s*$', re.MULTILINE) if pattern.search(gn_args): - return "chromeos" + return 'chromeos' except (ValueError, OSError) as e: logging.info(e) @@ -92,7 +91,7 @@ sheet_config = get_sheet_config(build_path) try: if rc == 0 and sheet_config is not None: - print("Tests succeeded. Updating annotations sheet...") + print('Tests succeeded. Updating annotations sheet...') config_file = tempfile.NamedTemporaryFile(delete=False, mode='w+') json.dump(sheet_config, config_file, indent=4) @@ -113,9 +112,9 @@ rc = common.run_command(command_line) cleanup_file(config_filename) else: - print("Test failed without updating the annotations sheet.") + print('Test failed without updating the annotations sheet.') except (ValueError, OSError) as e: - print("Error updating the annotations sheet", e) + print('Error updating the annotations sheet', e) traceback.print_exc() finally: cleanup_file(annotations_filename) @@ -130,7 +129,7 @@ try: os.remove(filename) except OSError: - print("Could not remove file: ", filename) + print('Could not remove file: ', filename) def main_compile_targets(args):
diff --git a/testing/test_env.py b/testing/test_env.py index a8d8115..1633ef5 100755 --- a/testing/test_env.py +++ b/testing/test_env.py
@@ -128,13 +128,13 @@ # Do not insert %c into LLVM_PROFILE_FILE if it's already there as that'll # cause the coverage instrumentation to write coverage data to default.profraw # instead of LLVM_PROFILE_FILE. - if "%c" in llvm_profile_file: + if '%c' in llvm_profile_file: return {'LLVM_PROFILE_FILE': llvm_profile_file} dirname, basename = os.path.split(llvm_profile_file) root, ext = os.path.splitext(basename) - return {'LLVM_PROFILE_FILE': os.path.join(dirname, root + "%c" + ext)} + return {'LLVM_PROFILE_FILE': os.path.join(dirname, root + '%c' + ext)} def get_sanitizer_symbolize_command(json_path=None, executable_path=None): @@ -174,7 +174,7 @@ raise if p.returncode != 0: - print("Error: failed to symbolize snippets in JSON:\n", file=sys.stderr) + print('Error: failed to symbolize snippets in JSON:\n', file=sys.stderr) print(stderr, file=sys.stderr) raise subprocess.CalledProcessError(p.returncode, symbolize_command) @@ -193,8 +193,8 @@ json_path = get_json_path(cmd) if json_path is None: print( - "Warning: Cannot escalate sanitizer warnings without a json summary " - "file:\n", + 'Warning: Cannot escalate sanitizer warnings without a json summary ' + 'file:\n', file=sys.stderr) return 0 @@ -208,7 +208,7 @@ raise if p.returncode != 0: - print("Error: failed to escalate sanitizer warnings status in JSON:\n", + print('Error: failed to escalate sanitizer warnings status in JSON:\n', file=sys.stderr) print(stderr, file=sys.stderr) return p.returncode @@ -327,7 +327,7 @@ if sys.platform == 'win32' and sig == signal.SIGBREAK: p.send_signal(signal.CTRL_BREAK_EVENT) else: - print("Forwarding signal(%d) to process %d" % (sig, p.pid)) + print('Forwarding signal(%d) to process %d' % (sig, p.pid)) p.send_signal(sig) # pylint: enable=no-member
diff --git a/testing/unexpected_passes_common/result_output.py b/testing/unexpected_passes_common/result_output.py index 8cc0f2eb..0559464 100644 --- a/testing/unexpected_passes_common/result_output.py +++ b/testing/unexpected_passes_common/result_output.py
@@ -326,7 +326,7 @@ _RecursiveHtmlToFile(active_str_dict, file_handle) if unused_expectations_str_list: - file_handle.write('\n<h1>' + SECTION_UNUSED + "</h1>\n") + file_handle.write('\n<h1>' + SECTION_UNUSED + '</h1>\n') _RecursiveHtmlToFile(unused_expectations_str_list, file_handle) if unmatched_results_str_dict: file_handle.write('\n<h1>' + SECTION_UNMATCHED + '</h1>\n') @@ -617,9 +617,9 @@ orphaned_urls: A list of strings containing URLs to output as closable. file_handle: A file handle to write the string to. Defaults to stdout. """ - _OutputUrlsForCommandLine(affected_urls, "Affected bugs", file_handle) + _OutputUrlsForCommandLine(affected_urls, 'Affected bugs', file_handle) if orphaned_urls: - _OutputUrlsForCommandLine(orphaned_urls, "Closable bugs", file_handle) + _OutputUrlsForCommandLine(orphaned_urls, 'Closable bugs', file_handle) def _OutputUrlsForCommandLine(urls: List[str],
diff --git a/testing/variations/PRESUBMIT.py b/testing/variations/PRESUBMIT.py index ff244f3..dc7ddde 100644 --- a/testing/variations/PRESUBMIT.py +++ b/testing/variations/PRESUBMIT.py
@@ -23,7 +23,7 @@ FIELDTRIAL_CONFIG_FILE_NAME = 'fieldtrial_testing_config.json' -BASE_FEATURE_PATTERN = r"BASE_FEATURE\((.*?),(.*?),(.*?)\);" +BASE_FEATURE_PATTERN = r'BASE_FEATURE\((.*?),(.*?),(.*?)\);' BASE_FEATURE_RE = re.compile(BASE_FEATURE_PATTERN, flags=re.MULTILINE + re.DOTALL) @@ -252,9 +252,9 @@ def _GetStudyConfigFeatures(study_config): """Gets the set of features overridden in a study config.""" features = set() - for experiment in study_config.get("experiments", []): - features.update(experiment.get("enable_features", [])) - features.update(experiment.get("disable_features", [])) + for experiment in study_config.get('experiments', []): + features.update(experiment.get('enable_features', [])) + features.update(experiment.get('disable_features', [])) return features @@ -263,11 +263,11 @@ duplicated_features = set() for study_config1 in study1: features = _GetStudyConfigFeatures(study_config1) - platforms = set(study_config1.get("platforms", [])) + platforms = set(study_config1.get('platforms', [])) for study_config2 in study2: # If the study configs do not specify any common platform, they do not # overlap, so we can skip them. - if platforms.isdisjoint(set(study_config2.get("platforms", []))): + if platforms.isdisjoint(set(study_config2.get('platforms', []))): continue common_features = features & _GetStudyConfigFeatures(study_config2) @@ -329,7 +329,7 @@ return [] duplicated_features_strings = [ - "%s (in studies %s)" % (feature, ', '.join(studies)) + '%s (in studies %s)' % (feature, ', '.join(studies)) for feature, studies in duplicated_features_to_studies_map.items() ] @@ -385,7 +385,7 @@ messages = [] # Join all changed lines into a single string. This will be used to check # if feature names are present in the changed lines by substring search. - changed_contents = " ".join([x[1].strip() for x in changed_lines]) + changed_contents = ' '.join([x[1].strip() for x in changed_lines]) for study_name in json_data: study = json_data[study_name] for config in study: @@ -406,23 +406,23 @@ # Warn, but don't break, if they are present in the CL cros_late_boot_features = { s - for s in missing_features if s.startswith("CrOSLateBoot") + for s in missing_features if s.startswith('CrOSLateBoot') } missing_features = missing_features - cros_late_boot_features if cros_late_boot_features: - msg = ("CrOSLateBoot features added to " - "study %s are not checked by presubmit." - "\nPlease manually check that they exist in the code base." + msg = ('CrOSLateBoot features added to ' + 'study %s are not checked by presubmit.' + '\nPlease manually check that they exist in the code base.' ) % study_name messages.append( output_api.PresubmitResult(msg, cros_late_boot_features)) if missing_features: - msg = ("Presubmit was unable to verify existence of features in " - "study %s.\nThis happens most commonly if the feature is " - "defined by code generation.\n" - "Please verify that the feature names have been spelled " - "correctly before submitting. The affected features are:" + msg = ('Presubmit was unable to verify existence of features in ' + 'study %s.\nThis happens most commonly if the feature is ' + 'defined by code generation.\n' + 'Please verify that the feature names have been spelled ' + 'correctly before submitting. The affected features are:' ) % study_name messages.append(output_api.PresubmitResult(msg, missing_features))
diff --git a/testing/variations/presubmit/find_features.py b/testing/variations/presubmit/find_features.py index 6c3ca48..3486c6c 100644 --- a/testing/variations/presubmit/find_features.py +++ b/testing/variations/presubmit/find_features.py
@@ -13,60 +13,60 @@ import pathlib import re -BASE_FEATURE_PATTERN = br"BASE_FEATURE\((.*?),(.*?),(.*?)\);" +BASE_FEATURE_PATTERN = br'BASE_FEATURE\((.*?),(.*?),(.*?)\);' BASE_FEATURE_RE = re.compile(BASE_FEATURE_PATTERN, flags=re.MULTILINE + re.DOTALL) # Only search these directories for flags. If your flag is outside these root # directories, then add the directory here. DIRECTORIES_TO_SEARCH = [ - "android_webview", - "apps", - "ash", - "base", - "cc", - "chrome", - "chromecast", - "chromeos", - "clank", - "components", - "content", - "courgette", - "crypto", - "dbus", - "device", - "extensions", - "fuchsia_web", - "gin", - "google_apis", - "google_update", - "gpu", - "headless", - "infra", - "internal", - "ios", - "ipc", - "media", - "mojo", - "native_client", - "native_client_sdk", - "net", - "pdf", - "ppapi", - "printing", - "remoting", - "rlz", - "sandbox", - "services", - "skia", - "sql", - "storage", + 'android_webview', + 'apps', + 'ash', + 'base', + 'cc', + 'chrome', + 'chromecast', + 'chromeos', + 'clank', + 'components', + 'content', + 'courgette', + 'crypto', + 'dbus', + 'device', + 'extensions', + 'fuchsia_web', + 'gin', + 'google_apis', + 'google_update', + 'gpu', + 'headless', + 'infra', + 'internal', + 'ios', + 'ipc', + 'media', + 'mojo', + 'native_client', + 'native_client_sdk', + 'net', + 'pdf', + 'ppapi', + 'printing', + 'remoting', + 'rlz', + 'sandbox', + 'services', + 'skia', + 'sql', + 'storage', # third_party/blink handled separately in FindDeclaredFeatures - "ui", - "url", - "v8", - "webkit", - "weblayer", + 'ui', + 'url', + 'v8', + 'webkit', + 'weblayer', ] @@ -76,7 +76,7 @@ matches = BASE_FEATURE_RE.finditer(file_contents) # Remove whitespace and surrounding " from the second argument # which is the feature name. - return [m.group(2).strip().strip(b'"').decode("utf-8") for m in matches] + return [m.group(2).strip().strip(b'"').decode('utf-8') for m in matches] def FindDeclaredFeatures(input_api): @@ -94,16 +94,16 @@ # Iterate over the search folders in the root. root = pathlib.Path(input_api.change.RepositoryRoot()) glob_patterns = [ - str(p / pathlib.Path("**/*.cc")) for p in root.iterdir() + str(p / pathlib.Path('**/*.cc')) for p in root.iterdir() if p.is_dir() and p.name in DIRECTORIES_TO_SEARCH ] # blink is the only directory in third_party that should be searched. - blink_glob = str(root / pathlib.Path("third_party/blink/**/*.cc")) + blink_glob = str(root / pathlib.Path('third_party/blink/**/*.cc')) glob_patterns.append(blink_glob) # Additional features for iOS can be found in mm files in the ios directory. - mm_glob = str(root / pathlib.Path("ios/**/*.mm")) + mm_glob = str(root / pathlib.Path('ios/**/*.mm')) glob_patterns.append(mm_glob) # Create glob iterators that lazily go over the files to search
diff --git a/testing/xvfb.py b/testing/xvfb.py index bcc72e59..fb782c65 100755 --- a/testing/xvfb.py +++ b/testing/xvfb.py
@@ -223,9 +223,8 @@ mode_labels = [] for width, height in mode_sizes: (modeline_label, modeline) = _make_xorg_modeline(width, height, 60) - modelines.append("Modeline \"%s\" %s" % - (modeline_label, " ".join(modeline))) - mode_labels.append("\"%s\"" % modeline_label) + modelines.append('Modeline "%s" %s' % (modeline_label, ' '.join(modeline))) + mode_labels.append('"%s"' % modeline_label) config = """ Section "Monitor" Identifier "Monitor0" @@ -248,7 +247,7 @@ Modes %s EndSubSection EndSection - """ % ("\n".join(modelines), depth, " ".join(mode_labels)) + """ % ('\n'.join(modelines), depth, ' '.join(mode_labels)) config_file = os.path.join(tempfile.gettempdir(), 'xorg-%s.config' % uuid.uuid4().hex) with open(config_file, 'w') as f: @@ -291,7 +290,7 @@ call_xrandr(args) # Sets the primary monitor to the default size and marks the rest as disabled. - call_xrandr(["-s", "%dx%d" % default_size]) + call_xrandr(['-s', '%dx%d' % default_size]) # Set the DPI to something realistic (as required by some desktops). call_xrandr(['--dpi', '96']) @@ -443,7 +442,7 @@ # a better solution is found, add a check for the "weston" binary here and # run tests without Wayland compositor if the weston binary is not found. # TODO(https://1178788): find a better solution. - if not os.path.isfile("./weston"): + if not os.path.isfile('./weston'): print('Weston is not available. Starting without Wayland compositor') return test_env.run_executable(cmd, env, stdoutfile, cwd)
diff --git a/testing/xvfb_unittest.py b/testing/xvfb_unittest.py index bdaeb74..3db425c 100755 --- a/testing/xvfb_unittest.py +++ b/testing/xvfb_unittest.py
@@ -77,7 +77,7 @@ self._procs.append(launch_process([])) self._procs[0].wait() - @unittest.skip("flaky; crbug.com/1320399") + @unittest.skip('flaky; crbug.com/1320399') def test_xvfb_race_condition(self): self._procs = [launch_process([]) for _ in range(15)] for proc in self._procs: