Move to Python3

Most of the changes have been made by 2to3. Some manual fiddling was
needed to make sure we're calling python3 instead of just python in the
tests. Two of the helpers in the tests were reworked into proper methods
rather than partials because we had to convert their returned value to
str and this seems like the most straightforward/easy-to-read way.

Change-Id: I74fdc1eaade3c026ee0c3e6bcdf26f8840f259b3
diff --git a/tests/unittests/testllvmsourceconfig.py b/tests/unittests/testllvmsourceconfig.py
index 1add13a..3ad93b1 100644
--- a/tests/unittests/testllvmsourceconfig.py
+++ b/tests/unittests/testllvmsourceconfig.py
@@ -45,7 +45,7 @@
         self.originalLLVM = Clone(self.proj, path)
 
         subprojs = LLVMSubproject.get_all_subprojects()
-        for subproj in subprojs.keys():
+        for subproj in list(subprojs.keys()):
             repo = self.__get_subproj_repo_path(subproj)
             self.__create_dummy_repo(repo)
 
@@ -170,8 +170,8 @@
         with self.assertRaises(ValueError) as context:
             config.update({subproj : Clone(self.proj, subprojPath)})
 
-        self.assertRegexpMatches(str(context.exception),
-                                 "Unknown llvm subproject %s" % subproj)
+        self.assertRegex(str(context.exception),
+                         "Unknown llvm subproject %s" % subproj)
 
     def test_add_each_subproject(self):
         sourcePath = self.temporaryLLVM.repodir
@@ -283,9 +283,9 @@
         with self.assertRaises(EnvironmentError) as context:
             config.update({ "lldb" : self.__get_subproj_repo("lldb")})
 
-        self.assertRegexpMatches(str(context.exception),
-                "{} already exists but is not a valid subproject directory.*"
-                .format(existingPath))
+        self.assertRegex(str(context.exception),
+                         "{} already exists but is not a valid subproject directory.*"
+                         .format(existingPath))
 
         # If we got this far, we're probably ok, but let's be pedantic and check
         # that the subproject is still there
@@ -313,9 +313,9 @@
         with self.assertRaises(EnvironmentError) as context:
             config.update({ "lldb" : self.__get_subproj_repo("lldb")})
 
-        self.assertRegexpMatches(str(context.exception),
-                "{} already exists but is not a valid subproject directory.*"
-                .format(existingPath))
+        self.assertRegex(str(context.exception),
+                         "{} already exists but is not a valid subproject directory.*"
+                         .format(existingPath))
 
         # If we got this far, we're probably ok, but let's be pedantic and check
         # that the subproject is still there
@@ -378,7 +378,7 @@
 
         subprojs = LLVMSubproject.get_all_subprojects()
 
-        for subproj in subprojs.keys():
+        for subproj in list(subprojs.keys()):
             path = subprojs[subproj].get_cmake_path(sourcePath)
             worktree = Worktree.create(
                 self.proj,
@@ -388,9 +388,9 @@
             self.assertTrue(os.path.isdir(path), "Failed to create worktree")
 
         config = LLVMSourceConfig(self.proj, sourcePath)
-        config.update(remove=subprojs.keys())
+        config.update(remove=list(subprojs.keys()))
 
-        for subproj in subprojs.keys():
+        for subproj in list(subprojs.keys()):
             path = subprojs[subproj].get_cmake_path(sourcePath)
             self.assertFalse(
                 os.path.isdir(path),
@@ -401,7 +401,7 @@
 
         subprojs = LLVMSubproject.get_all_subprojects()
 
-        for subproj in subprojs.keys():
+        for subproj in list(subprojs.keys()):
             path = subprojs[subproj].get_cmake_path(sourcePath)
             worktree = Worktree.create(
                 self.proj,
@@ -412,10 +412,10 @@
 
         config = LLVMSourceConfig(self.proj, sourcePath)
 
-        for subproj in subprojs.keys():
+        for subproj in list(subprojs.keys()):
             config.update(remove=[subproj])
 
-        for subproj in subprojs.keys():
+        for subproj in list(subprojs.keys()):
             path = subprojs[subproj].get_cmake_path(sourcePath)
             self.assertFalse(
                 os.path.isdir(path),
@@ -456,8 +456,8 @@
         with self.assertRaises(ValueError) as context:
             config.update(remove=[subproj])
 
-        self.assertRegexpMatches(str(context.exception),
-                                 "Unknown llvm subproject %s" % subproj)
+        self.assertRegex(str(context.exception),
+                         "Unknown llvm subproject %s" % subproj)
 
     def test_remove_inexistent_subproject(self):
         sourcePath = self.temporaryLLVM.repodir