cleanup: Update codebase to expect Python 3.6

- Bump minimum version to Python 3.6.
- Use f-strings in a lot of places.

Change-Id: I2aa70197230fcec2eff8e7c8eb754f20c08075bb
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/389034
Tested-by: Jason R. Coombs <jaraco@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Jason R. Coombs <jaraco@google.com>
This commit is contained in:
Jason R. Coombs
2023-09-29 11:04:49 -04:00
committed by LUCI
parent b99272c601
commit b32ccbb66b
33 changed files with 169 additions and 225 deletions

View File

@ -19,12 +19,7 @@ import os
import re
import subprocess
import unittest
try:
from unittest import mock
except ImportError:
import mock
from unittest import mock
import git_command
import wrapper

View File

@ -100,7 +100,7 @@ class GitConfigReadOnlyTests(unittest.TestCase):
("intg", 10737418240),
)
for key, value in TESTS:
self.assertEqual(value, self.config.GetInt("section.%s" % (key,)))
self.assertEqual(value, self.config.GetInt(f"section.{key}"))
class GitConfigReadWriteTests(unittest.TestCase):

View File

@ -34,7 +34,7 @@ class SuperprojectTestCase(unittest.TestCase):
PARENT_SID_KEY = "GIT_TRACE2_PARENT_SID"
PARENT_SID_VALUE = "parent_sid"
SELF_SID_REGEX = r"repo-\d+T\d+Z-.*"
FULL_SID_REGEX = r"^%s/%s" % (PARENT_SID_VALUE, SELF_SID_REGEX)
FULL_SID_REGEX = rf"^{PARENT_SID_VALUE}/{SELF_SID_REGEX}"
def setUp(self):
"""Set up superproject every time."""

View File

@ -61,7 +61,7 @@ class EventLogTestCase(unittest.TestCase):
PARENT_SID_KEY = "GIT_TRACE2_PARENT_SID"
PARENT_SID_VALUE = "parent_sid"
SELF_SID_REGEX = r"repo-\d+T\d+Z-.*"
FULL_SID_REGEX = r"^%s/%s" % (PARENT_SID_VALUE, SELF_SID_REGEX)
FULL_SID_REGEX = rf"^{PARENT_SID_VALUE}/{SELF_SID_REGEX}"
def setUp(self):
"""Load the event_log module every time."""

View File

@ -198,13 +198,13 @@ class ValueTests(unittest.TestCase):
def test_bool_true(self):
"""Check XmlBool true values."""
for value in ("yes", "true", "1"):
node = self._get_node('<node a="%s"/>' % (value,))
node = self._get_node(f'<node a="{value}"/>')
self.assertTrue(manifest_xml.XmlBool(node, "a"))
def test_bool_false(self):
"""Check XmlBool false values."""
for value in ("no", "false", "0"):
node = self._get_node('<node a="%s"/>' % (value,))
node = self._get_node(f'<node a="{value}"/>')
self.assertFalse(manifest_xml.XmlBool(node, "a"))
def test_int_default(self):
@ -220,7 +220,7 @@ class ValueTests(unittest.TestCase):
def test_int_good(self):
"""Check XmlInt numeric handling."""
for value in (-1, 0, 1, 50000):
node = self._get_node('<node a="%s"/>' % (value,))
node = self._get_node(f'<node a="{value}"/>')
self.assertEqual(value, manifest_xml.XmlInt(node, "a"))
def test_int_invalid(self):

View File

@ -151,7 +151,7 @@ class CopyLinkTestCase(unittest.TestCase):
# "".
break
result = os.path.exists(path)
msg.append("\tos.path.exists(%s): %s" % (path, result))
msg.append(f"\tos.path.exists({path}): {result}")
if result:
msg.append("\tcontents: %r" % os.listdir(path))
break