From b32ccbb66bb16965ecb8b4e266c4e45186636c1b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 29 Sep 2023 11:04:49 -0400 Subject: 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 Reviewed-by: Mike Frysinger Commit-Queue: Jason R. Coombs --- tests/test_git_command.py | 7 +------ tests/test_git_config.py | 2 +- tests/test_git_superproject.py | 2 +- tests/test_git_trace2_event_log.py | 2 +- tests/test_manifest_xml.py | 6 +++--- tests/test_project.py | 2 +- 6 files changed, 8 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/test_git_command.py b/tests/test_git_command.py index 7c108ccd..ffee023b 100644 --- a/tests/test_git_command.py +++ b/tests/test_git_command.py @@ -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 diff --git a/tests/test_git_config.py b/tests/test_git_config.py index a44dca0f..cf6e7793 100644 --- a/tests/test_git_config.py +++ b/tests/test_git_config.py @@ -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): diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index 478ebca7..4e66521b 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -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.""" diff --git a/tests/test_git_trace2_event_log.py b/tests/test_git_trace2_event_log.py index d8e963dd..4658a793 100644 --- a/tests/test_git_trace2_event_log.py +++ b/tests/test_git_trace2_event_log.py @@ -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.""" diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index bd255dcc..3fcf09fa 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -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('' % (value,)) + node = self._get_node(f'') 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('' % (value,)) + node = self._get_node(f'') 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('' % (value,)) + node = self._get_node(f'') self.assertEqual(value, manifest_xml.XmlInt(node, "a")) def test_int_invalid(self): diff --git a/tests/test_project.py b/tests/test_project.py index 83cfe0a4..6dc071bd 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -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 -- cgit v1.2.3-54-g00ecf