Commit 54086c21 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Fix styling errors in PRESUBMIT_test.py

Most errors found by flake8 are fixed. The exceptions are:
- E111: indentation is not a multiple of four
- E121: continuation line under-indented for hanging indent
- E501: line too long (> 79 characters)

Bug: None
Change-Id: I6d85b3b170d5e0682e30c564e9dbaf185bb55168
Reviewed-on: https://chromium-review.googlesource.com/1152125Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578814}
parent c1a2895d
...@@ -4,16 +4,17 @@ ...@@ -4,16 +4,17 @@
# found in the LICENSE file. # found in the LICENSE file.
import os.path import os.path
import re
import subprocess import subprocess
import unittest import unittest
import PRESUBMIT import PRESUBMIT
from PRESUBMIT_test_mocks import MockChange, MockFile, MockAffectedFile from PRESUBMIT_test_mocks import MockFile, MockAffectedFile
from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
_TEST_DATA_DIR = 'base/test/data/presubmit' _TEST_DATA_DIR = 'base/test/data/presubmit'
class VersionControlConflictsTest(unittest.TestCase): class VersionControlConflictsTest(unittest.TestCase):
def testTypicalConflict(self): def testTypicalConflict(self):
lines = ['<<<<<<< HEAD', lines = ['<<<<<<< HEAD',
...@@ -38,6 +39,7 @@ class VersionControlConflictsTest(unittest.TestCase): ...@@ -38,6 +39,7 @@ class VersionControlConflictsTest(unittest.TestCase):
MockInputApi(), MockFile('some/polymer/README.md', lines)) MockInputApi(), MockFile('some/polymer/README.md', lines))
self.assertEqual(0, len(errors)) self.assertEqual(0, len(errors))
class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
def testTypicalCorrectlyMatchedChange(self): def testTypicalCorrectlyMatchedChange(self):
diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
...@@ -131,8 +133,8 @@ class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): ...@@ -131,8 +133,8 @@ class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
# "Dummy\", true); // The \"correct" # "Dummy\", true); // The \"correct"
diff_cc = ['UMA_HISTOGRAM_BOOL("Dummy", true); // The "correct" histogram'] diff_cc = ['UMA_HISTOGRAM_BOOL("Dummy", true); // The "correct" histogram']
diff_java = [ diff_java = [
'RecordHistogram.recordBooleanHistogram("Dummy", true);' 'RecordHistogram.recordBooleanHistogram("Dummy", true);' +
+ ' // The "correct" histogram'] ' // The "correct" histogram']
diff_xml = ['<histogram name="Dummy"> </histogram>'] diff_xml = ['<histogram name="Dummy"> </histogram>']
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
mock_input_api.files = [ mock_input_api.files = [
...@@ -177,6 +179,7 @@ class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): ...@@ -177,6 +179,7 @@ class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
self.assertTrue('foo.cc' in warnings[0].items[0]) self.assertTrue('foo.cc' in warnings[0].items[0])
self.assertTrue('foo2.cc' in warnings[0].items[1]) self.assertTrue('foo2.cc' in warnings[0].items[1])
class BadExtensionsTest(unittest.TestCase): class BadExtensionsTest(unittest.TestCase):
def testBadRejFile(self): def testBadRejFile(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
...@@ -274,14 +277,14 @@ class InvalidIfDefinedMacroNamesTest(unittest.TestCase): ...@@ -274,14 +277,14 @@ class InvalidIfDefinedMacroNamesTest(unittest.TestCase):
' # ifdef TARGET_IPHONE_SIMULATOR', ' # ifdef TARGET_IPHONE_SIMULATOR',
'# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)', '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)',
'# else // defined(TARGET_IPHONE_SIMULATOR)', '# else // defined(TARGET_IPHONE_SIMULATOR)',
'#endif // defined(TARGET_IPHONE_SIMULATOR)',] '#endif // defined(TARGET_IPHONE_SIMULATOR)']
errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile( errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
MockInputApi(), MockFile('some/path/source.mm', lines)) MockInputApi(), MockFile('some/path/source.mm', lines))
self.assertEqual(len(lines), len(errors)) self.assertEqual(len(lines), len(errors))
def testValidIfDefinedMacroNames(self): def testValidIfDefinedMacroNames(self):
lines = ['#if defined(FOO)', lines = ['#if defined(FOO)',
'#ifdef BAR',] '#ifdef BAR']
errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile( errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
MockInputApi(), MockFile('some/path/source.cc', lines)) MockInputApi(), MockFile('some/path/source.cc', lines))
self.assertEqual(0, len(errors)) self.assertEqual(0, len(errors))
...@@ -671,7 +674,6 @@ class UserMetricsActionTest(unittest.TestCase): ...@@ -671,7 +674,6 @@ class UserMetricsActionTest(unittest.TestCase):
self.assertEqual( self.assertEqual(
[], PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi())) [], PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi()))
def testUserMetricsActionNotAddedToActions(self): def testUserMetricsActionNotAddedToActions(self):
input_api = MockInputApi() input_api = MockInputApi()
file_with_user_action = 'file_with_user_action.cc' file_with_user_action = 'file_with_user_action.cc'
...@@ -824,6 +826,7 @@ class PydepsNeedsUpdatingTest(unittest.TestCase): ...@@ -824,6 +826,7 @@ class PydepsNeedsUpdatingTest(unittest.TestCase):
self.assertTrue('File is stale' in str(results[0])) self.assertTrue('File is stale' in str(results[0]))
self.assertTrue('File is stale' in str(results[1])) self.assertTrue('File is stale' in str(results[1]))
class IncludeGuardTest(unittest.TestCase): class IncludeGuardTest(unittest.TestCase):
def testIncludeGuardChecks(self): def testIncludeGuardChecks(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
...@@ -950,40 +953,41 @@ class IncludeGuardTest(unittest.TestCase): ...@@ -950,40 +953,41 @@ class IncludeGuardTest(unittest.TestCase):
self.assertEqual(expected_fail_count, len(msgs), self.assertEqual(expected_fail_count, len(msgs),
'Expected %d items, found %d: %s' 'Expected %d items, found %d: %s'
% (expected_fail_count, len(msgs), msgs)) % (expected_fail_count, len(msgs), msgs))
self.assertEqual(msgs[0].items, [ 'content/browser/thing/bar.h' ]) self.assertEqual(msgs[0].items, ['content/browser/thing/bar.h'])
self.assertEqual(msgs[0].message, self.assertEqual(msgs[0].message,
'Include guard CONTENT_BROWSER_THING_BAR_H_ ' 'Include guard CONTENT_BROWSER_THING_BAR_H_ '
'not covering the whole file') 'not covering the whole file')
self.assertEqual(msgs[1].items, [ 'content/browser/test1.h' ]) self.assertEqual(msgs[1].items, ['content/browser/test1.h'])
self.assertEqual(msgs[1].message, self.assertEqual(msgs[1].message,
'Missing include guard CONTENT_BROWSER_TEST1_H_') 'Missing include guard CONTENT_BROWSER_TEST1_H_')
self.assertEqual(msgs[2].items, [ 'content/browser/test2.h:3' ]) self.assertEqual(msgs[2].items, ['content/browser/test2.h:3'])
self.assertEqual(msgs[2].message, self.assertEqual(msgs[2].message,
'Missing "#define CONTENT_BROWSER_TEST2_H_" for ' 'Missing "#define CONTENT_BROWSER_TEST2_H_" for '
'include guard') 'include guard')
self.assertEqual(msgs[3].items, [ 'content/browser/spleling.h:1' ]) self.assertEqual(msgs[3].items, ['content/browser/spleling.h:1'])
self.assertEqual(msgs[3].message, self.assertEqual(msgs[3].message,
'Header using the wrong include guard name ' 'Header using the wrong include guard name '
'CONTENT_BROWSER_SPLLEING_H_') 'CONTENT_BROWSER_SPLLEING_H_')
self.assertEqual(msgs[4].items, [ 'content/NotInBlink.h:1' ]) self.assertEqual(msgs[4].items, ['content/NotInBlink.h:1'])
self.assertEqual(msgs[4].message, self.assertEqual(msgs[4].message,
'Header using the wrong include guard name ' 'Header using the wrong include guard name '
'NotInBlink_h') 'NotInBlink_h')
self.assertEqual(msgs[5].items, [ 'third_party/blink/InBlink.h:1' ]) self.assertEqual(msgs[5].items, ['third_party/blink/InBlink.h:1'])
self.assertEqual(msgs[5].message, self.assertEqual(msgs[5].message,
'Header using the wrong include guard name ' 'Header using the wrong include guard name '
'InBlink_h') 'InBlink_h')
self.assertEqual(msgs[6].items, [ 'third_party/blink/AlsoInBlink.h:1' ]) self.assertEqual(msgs[6].items, ['third_party/blink/AlsoInBlink.h:1'])
self.assertEqual(msgs[6].message, self.assertEqual(msgs[6].message,
'Header using the wrong include guard name ' 'Header using the wrong include guard name '
'WrongInBlink_h') 'WrongInBlink_h')
class AndroidDeprecatedTestAnnotationTest(unittest.TestCase): class AndroidDeprecatedTestAnnotationTest(unittest.TestCase):
def testCheckAndroidTestAnnotationUsage(self): def testCheckAndroidTestAnnotationUsage(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
...@@ -1029,6 +1033,7 @@ class AndroidDeprecatedTestAnnotationTest(unittest.TestCase): ...@@ -1029,6 +1033,7 @@ class AndroidDeprecatedTestAnnotationTest(unittest.TestCase):
self.assertTrue('UsedDeprecatedSmokeAnnotation.java:1' in msgs[0].items, self.assertTrue('UsedDeprecatedSmokeAnnotation.java:1' in msgs[0].items,
'UsedDeprecatedSmokeAnnotation not found in errors') 'UsedDeprecatedSmokeAnnotation not found in errors')
class AndroidDeprecatedJUnitFrameworkTest(unittest.TestCase): class AndroidDeprecatedJUnitFrameworkTest(unittest.TestCase):
def testCheckAndroidTestJUnitFramework(self): def testCheckAndroidTestJUnitFramework(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
...@@ -1063,6 +1068,7 @@ class AndroidDeprecatedJUnitFrameworkTest(unittest.TestCase): ...@@ -1063,6 +1068,7 @@ class AndroidDeprecatedJUnitFrameworkTest(unittest.TestCase):
in msgs[0].items, in msgs[0].items,
'UsedDeprecatedJUnitAssert not found in errors') 'UsedDeprecatedJUnitAssert not found in errors')
class AndroidJUnitBaseClassTest(unittest.TestCase): class AndroidJUnitBaseClassTest(unittest.TestCase):
def testCheckAndroidTestJUnitBaseClass(self): def testCheckAndroidTestJUnitBaseClass(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
...@@ -1119,6 +1125,7 @@ class AndroidJUnitBaseClassTest(unittest.TestCase): ...@@ -1119,6 +1125,7 @@ class AndroidJUnitBaseClassTest(unittest.TestCase):
self.assertTrue('IncorrectMultiLineTest.java:2' in msgs[0].items, self.assertTrue('IncorrectMultiLineTest.java:2' in msgs[0].items,
'IncorrectMultiLineTest not found in errors') 'IncorrectMultiLineTest not found in errors')
class LogUsageTest(unittest.TestCase): class LogUsageTest(unittest.TestCase):
def testCheckAndroidCrLogUsage(self): def testCheckAndroidCrLogUsage(self):
...@@ -1244,6 +1251,7 @@ class LogUsageTest(unittest.TestCase): ...@@ -1244,6 +1251,7 @@ class LogUsageTest(unittest.TestCase):
self.assertTrue('HasDottedTag.java' in msgs[4].items) self.assertTrue('HasDottedTag.java' in msgs[4].items)
self.assertTrue('HasOldTag.java' in msgs[4].items) self.assertTrue('HasOldTag.java' in msgs[4].items)
class GoogleAnswerUrlFormatTest(unittest.TestCase): class GoogleAnswerUrlFormatTest(unittest.TestCase):
def testCatchAnswerUrlId(self): def testCatchAnswerUrlId(self):
...@@ -1274,6 +1282,7 @@ class GoogleAnswerUrlFormatTest(unittest.TestCase): ...@@ -1274,6 +1282,7 @@ class GoogleAnswerUrlFormatTest(unittest.TestCase):
input_api, MockOutputApi()) input_api, MockOutputApi())
self.assertEqual(0, len(warnings)) self.assertEqual(0, len(warnings))
class HardcodedGoogleHostsTest(unittest.TestCase): class HardcodedGoogleHostsTest(unittest.TestCase):
def testWarnOnAssignedLiterals(self): def testWarnOnAssignedLiterals(self):
...@@ -1425,6 +1434,7 @@ class RiskyJsTest(unittest.TestCase): ...@@ -1425,6 +1434,7 @@ class RiskyJsTest(unittest.TestCase):
mock_input_api, mock_output_api) mock_input_api, mock_output_api)
self.assertEqual(2, len(warnings)) self.assertEqual(2, len(warnings))
class RelativeIncludesTest(unittest.TestCase): class RelativeIncludesTest(unittest.TestCase):
def testThirdPartyNotWebKitIgnored(self): def testThirdPartyNotWebKitIgnored(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
...@@ -1547,7 +1557,7 @@ class CrbugUrlFormatTest(unittest.TestCase): ...@@ -1547,7 +1557,7 @@ class CrbugUrlFormatTest(unittest.TestCase):
warnings = PRESUBMIT._CheckCrbugLinksHaveHttps(input_api, MockOutputApi()) warnings = PRESUBMIT._CheckCrbugLinksHaveHttps(input_api, MockOutputApi())
self.assertEqual(1, len(warnings)) self.assertEqual(1, len(warnings))
self.assertEqual(3, warnings[0].message.count('\n')); self.assertEqual(3, warnings[0].message.count('\n'))
class BannedFunctionCheckTest(unittest.TestCase): class BannedFunctionCheckTest(unittest.TestCase):
...@@ -1611,11 +1621,11 @@ class NoProductionJavaCodeUsingTestOnlyFunctionsTest(unittest.TestCase): ...@@ -1611,11 +1621,11 @@ class NoProductionJavaCodeUsingTestOnlyFunctionsTest(unittest.TestCase):
mock_input_api.files = [ mock_input_api.files = [
MockFile('dir/java/src/foo.java', ['FooForTesting();']), MockFile('dir/java/src/foo.java', ['FooForTesting();']),
MockFile('dir/java/src/bar.java', ['FooForTests(x);']), MockFile('dir/java/src/bar.java', ['FooForTests(x);']),
MockFile('dir/java/src/baz.java', ['FooForTest(','y',');']), MockFile('dir/java/src/baz.java', ['FooForTest(', 'y', ');']),
MockFile('dir/java/src/mult.java', [ MockFile('dir/java/src/mult.java', [
'int x = SomethingLongHere()', 'int x = SomethingLongHere()',
' * SomethingLongHereForTesting();' ' * SomethingLongHereForTesting();'
]), ])
] ]
results = PRESUBMIT._CheckNoProductionCodeUsingTestOnlyFunctionsJava( results = PRESUBMIT._CheckNoProductionCodeUsingTestOnlyFunctionsJava(
...@@ -1634,8 +1644,8 @@ class NoProductionJavaCodeUsingTestOnlyFunctionsTest(unittest.TestCase): ...@@ -1634,8 +1644,8 @@ class NoProductionJavaCodeUsingTestOnlyFunctionsTest(unittest.TestCase):
MockFile('dir/java/src/foo.java', ['FooForTests() {']), MockFile('dir/java/src/foo.java', ['FooForTests() {']),
MockFile('dir/java/src/bar.java', ['// FooForTest();']), MockFile('dir/java/src/bar.java', ['// FooForTest();']),
MockFile('dir/java/src/bar2.java', ['x = 1; // FooForTest();']), MockFile('dir/java/src/bar2.java', ['x = 1; // FooForTest();']),
MockFile('dir/javatests/src/baz.java', ['FooForTest(','y',');']), MockFile('dir/javatests/src/baz.java', ['FooForTest(', 'y', ');']),
MockFile('dir/junit/src/baz.java', ['FooForTest(','y',');']), MockFile('dir/junit/src/baz.java', ['FooForTest(', 'y', ');']),
MockFile('dir/junit/src/javadoc.java', [ MockFile('dir/junit/src/javadoc.java', [
'/** Use FooForTest(); to obtain foo in tests.' '/** Use FooForTest(); to obtain foo in tests.'
' */' ' */'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment