Convert tools/vim to python3

Bug: 1212119
Change-Id: I743f997826117526f6737e4d0398bed7dedf3d5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2930878
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Dan H <[email protected]>
Cr-Commit-Position: refs/heads/master@{#888238}
NOKEYCHECK=True
GitOrigin-RevId: dbdf14a371a85b22f047f8ac889d83f1661e757b
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 1cd25f9..06b5bd3 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -6,6 +6,8 @@
 Runs Python unit tests in /tools/vim/tests on upload.
 """
 
+USE_PYTHON3 = True
+
 
 def CheckChangeOnUpload(input_api, output_api):
   results = []
diff --git a/tests/chromium.ycm_extra_conf_unittest.py b/tests/chromium.ycm_extra_conf_unittest.py
index 3662fee..6c00d2b 100755
--- a/tests/chromium.ycm_extra_conf_unittest.py
+++ b/tests/chromium.ycm_extra_conf_unittest.py
@@ -140,33 +140,31 @@
   def testFindChromeSrc(self):
     chrome_source = self.ycm_extra_conf.FindChromeSrcFromFilename(
         os.path.join(self.chrome_root, 'chrome', 'one.cpp'))
-    self.assertEquals(chrome_source, self.chrome_root)
+    self.assertEqual(chrome_source, self.chrome_root)
 
     chrome_source = self.ycm_extra_conf.FindChromeSrcFromFilename(
         os.path.join(self.chrome_root, 'one.cpp'))
-    self.assertEquals(chrome_source, self.chrome_root)
+    self.assertEqual(chrome_source, self.chrome_root)
 
   def testCommandLineForKnownCppFile(self):
     command_line = self.ycm_extra_conf.GetClangCommandLineFromNinjaForSource(
         self.out_dir, os.path.join(self.chrome_root, 'one.cpp'))
-    self.assertEquals(command_line,
-                      ('../../fake-clang++ -Ia -Itag-one ../../one.cpp '
-                       '-o obj/one.o'))
+    self.assertEqual(command_line,
+                     ('../../fake-clang++ -Ia -Itag-one ../../one.cpp '
+                      '-o obj/one.o'))
 
   def testCommandLineForUnknownCppFile(self):
     command_line = self.ycm_extra_conf.GetClangCommandLineFromNinjaForSource(
         self.out_dir, os.path.join(self.chrome_root, 'unknown.cpp'))
-    self.assertEquals(command_line, None)
+    self.assertEqual(command_line, None)
 
   def testGetClangOptionsForKnownCppFile(self):
     clang_options = \
         self.ycm_extra_conf.GetClangOptionsFromNinjaForFilename(
             self.chrome_root, os.path.join(self.chrome_root, 'one.cpp'))
-    self.assertEquals(
-        self.NormalizeStringsInList(clang_options), [
-            '-I[SRC]', '-Wno-unknown-warning-option', '-I[OUT]/a',
-            '-I[OUT]/tag-one'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(clang_options), [
+        '-I[SRC]', '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-one'
+    ])
 
   def testOutDirNames(self):
     out_root = os.path.join(self.chrome_root, 'out_with_underscore')
@@ -188,11 +186,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-one'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-one'
+    ])
 
   def testGetFlagsForFileForUnknownCppFile(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -201,11 +198,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
+    ])
 
   def testGetFlagsForFileForUnknownCppNotTestFile(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -214,11 +210,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
+    ])
 
   testGetFlagsForFileForKnownObjcFile = TestLanguage('eight.m', 'objective-c')
   testGetFlagsForFileForKnownObjcHeaderFile = TestLanguage(
@@ -239,11 +234,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
+    ])
 
   def testGetFlagsForFileForUnknownUnittestFile(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -252,12 +246,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a',
-            '-I[OUT]/tag-default-test'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default-test'
+    ])
 
   def testGetFlagsForFileForUnknownBrowsertestFile2(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -266,12 +258,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a',
-            '-I[OUT]/tag-default-test'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default-test'
+    ])
 
   def testGetFlagsForFileForKnownHeaderFileWithAssociatedCppFile(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -280,11 +270,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-three'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-three'
+    ])
 
   def testSourceFileWithNonClangOutputs(self):
     # Verify assumption that four.cc has non-compiler-output listed as the first
@@ -296,10 +285,11 @@
         universal_newlines=True)
     stdout, _ = p.communicate()
     self.assertFalse(p.returncode)
-    self.assertEquals(stdout, '../../four.cc:\n'
-                      '  outputs:\n'
-                      '    obj/linker-output.o\n'
-                      '    obj/four.o\n')
+    self.assertEqual(
+        stdout, '../../four.cc:\n'
+        '  outputs:\n'
+        '    obj/linker-output.o\n'
+        '    obj/four.o\n')
 
     result = self.ycm_extra_conf.FlagsForFile(
         os.path.join(self.chrome_root, 'four.cc'))
@@ -307,11 +297,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-four'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-four'
+    ])
 
   def testSourceFileWithOnlyNonClangOutputs(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -320,11 +309,10 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
-            '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/a', '-I[OUT]/tag-default'
+    ])
 
   def testGetFlagsForSysrootAbsPath(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -333,19 +321,18 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER',
-            '-std=c++14',
-            '-x',
-            'c++',
-            '-I[SRC]',
-            '-Wno-unknown-warning-option',
-            '-I[OUT]/a',
-            '--sysroot=/usr/lib/sysroot-image',
-            '-isysroot',
-            '/mac.sdk',
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER',
+        '-std=c++14',
+        '-x',
+        'c++',
+        '-I[SRC]',
+        '-Wno-unknown-warning-option',
+        '-I[OUT]/a',
+        '--sysroot=/usr/lib/sysroot-image',
+        '-isysroot',
+        '/mac.sdk',
+    ])
 
   def testGetFlagsForSysrootRelPath(self):
     result = self.ycm_extra_conf.FlagsForFile(
@@ -354,55 +341,39 @@
     self.assertTrue('do_cache' in result)
     self.assertTrue(result['do_cache'])
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER',
-            '-std=c++14',
-            '-x',
-            'c++',
-            '-I[SRC]',
-            '-Wno-unknown-warning-option',
-            '-I[OUT]/a',
-            '--sysroot=[SRC]/build/sysroot-image',
-            '-isysroot',
-            '[SRC]/build/mac.sdk',
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER',
+        '-std=c++14',
+        '-x',
+        'c++',
+        '-I[SRC]',
+        '-Wno-unknown-warning-option',
+        '-I[OUT]/a',
+        '--sysroot=[SRC]/build/sysroot-image',
+        '-isysroot',
+        '[SRC]/build/mac.sdk',
+    ])
 
   def testGetFlagsForIsystem(self):
     result = self.ycm_extra_conf.FlagsForFile(
         os.path.join(self.chrome_root, 'ten.cc'))
     self.assertTrue(result)
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER',
-            '-std=c++14',
-            '-x',
-            'c++',
-            '-I[SRC]',
-            '-Wno-unknown-warning-option',
-            '-I[OUT]/b',
-            '-isystem[OUT]/a',
-            '-isystem', '[SRC]/build/c',
-            '-isystem', '/usr/lib/include'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I[OUT]/b', '-isystem[OUT]/a',
+        '-isystem', '[SRC]/build/c', '-isystem', '/usr/lib/include'
+    ])
 
   def testGetFlagsTwoPartI(self):
     result = self.ycm_extra_conf.FlagsForFile(
         os.path.join(self.chrome_root, 'eleven.cc'))
     self.assertTrue(result)
     self.assertTrue('flags' in result)
-    self.assertEquals(
-        self.NormalizeStringsInList(result['flags']), [
-            '-DUSE_CLANG_COMPLETER',
-            '-std=c++14',
-            '-x',
-            'c++',
-            '-I[SRC]',
-            '-Wno-unknown-warning-option',
-            '-I', '[OUT]/a',
-            '-I', '[OUT]/tag-eleven'
-        ])
+    self.assertEqual(self.NormalizeStringsInList(result['flags']), [
+        '-DUSE_CLANG_COMPLETER', '-std=c++14', '-x', 'c++', '-I[SRC]',
+        '-Wno-unknown-warning-option', '-I', '[OUT]/a', '-I', '[OUT]/tag-eleven'
+    ])
 
 
 if __name__ == '__main__':