From 93da17f5c3ca624ac22f371284a76f3641c60e1e Mon Sep 17 00:00:00 2001 From: newwingbird <62642238+newwingbird@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:44:03 +0900 Subject: [PATCH] replaced by fstring (#702) --- comtypes/test/test_BSTR.py | 2 +- comtypes/test/test_avmc.py | 2 +- comtypes/test/test_casesensitivity.py | 8 +++----- comtypes/test/test_collections.py | 6 +++--- comtypes/test/test_comserver.py | 6 +++--- comtypes/test/test_createwrappers.py | 4 ++-- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/comtypes/test/test_BSTR.py b/comtypes/test/test_BSTR.py index 8b5afc69c..1931c560e 100644 --- a/comtypes/test/test_BSTR.py +++ b/comtypes/test/test_BSTR.py @@ -8,7 +8,7 @@ class Test(unittest.TestCase): def check_leaks(self, func, limit=0): bytes = find_memleak(func) - self.assertFalse(bytes > limit, "Leaks %d bytes" % bytes) + self.assertFalse(bytes > limit, f"Leaks {bytes} bytes") def test_creation(self): def doit(): diff --git a/comtypes/test/test_avmc.py b/comtypes/test/test_avmc.py index 26e653aea..6204b4dfb 100644 --- a/comtypes/test/test_avmc.py +++ b/comtypes/test/test_avmc.py @@ -37,7 +37,7 @@ def test(self): def check_leaks(self, func, limit=0): bytes = find_memleak(func) - self.assertFalse(bytes > limit, "Leaks %d bytes" % bytes) + self.assertFalse(bytes > limit, f"Leaks {bytes} bytes") if __name__ == "__main__": diff --git a/comtypes/test/test_casesensitivity.py b/comtypes/test/test_casesensitivity.py index 3820fd94a..ae93345d4 100644 --- a/comtypes/test/test_casesensitivity.py +++ b/comtypes/test/test_casesensitivity.py @@ -31,13 +31,11 @@ def test(self): # names in the base class __map_case__ must also appear in the # subclass. for name in iem.IWebBrowser.__map_case__: - self.assertTrue( - name in iem.IWebBrowserApp.__map_case__, "%s missing" % name - ) - self.assertTrue(name in iem.IWebBrowser2.__map_case__, "%s missing" % name) + self.assertTrue(name in iem.IWebBrowserApp.__map_case__, f"{name} missing") + self.assertTrue(name in iem.IWebBrowser2.__map_case__, f"{name} missing") for name in iem.IWebBrowserApp.__map_case__: - self.assertTrue(name in iem.IWebBrowser2.__map_case__, "%s missing" % name) + self.assertTrue(name in iem.IWebBrowser2.__map_case__, f"{name} missing") if __name__ == "__main__": diff --git a/comtypes/test/test_collections.py b/comtypes/test/test_collections.py index 943c608b0..93f367208 100644 --- a/comtypes/test/test_collections.py +++ b/comtypes/test/test_collections.py @@ -74,7 +74,7 @@ def doit(): item.ProcessImageFileName bytes = find_memleak(doit, (20, 20)) - self.assertFalse(bytes, "Leaks %d bytes" % bytes) + self.assertFalse(bytes, f"Leaks {bytes} bytes") @unittest.skip("This test takes a long time. Do we need it? Can it be rewritten?") def test_leaks_2(self): @@ -87,7 +87,7 @@ def doit(): iter(apps).Next(99) bytes = find_memleak(doit, (20, 20)) - self.assertFalse(bytes, "Leaks %d bytes" % bytes) + self.assertFalse(bytes, f"Leaks {bytes} bytes") @unittest.skip("This test takes a long time. Do we need it? Can it be rewritten?") def test_leaks_3(self): @@ -102,7 +102,7 @@ def doit(): pass bytes = find_memleak(doit, (20, 20)) - self.assertFalse(bytes, "Leaks %d bytes" % bytes) + self.assertFalse(bytes, f"Leaks {bytes} bytes") class TestCollectionInterface(unittest.TestCase): diff --git a/comtypes/test/test_comserver.py b/comtypes/test/test_comserver.py index 23fd0c351..5d5191a38 100644 --- a/comtypes/test/test_comserver.py +++ b/comtypes/test/test_comserver.py @@ -39,7 +39,7 @@ def create_object(self) -> Any: ... def _find_memleak(self, func): bytes = find_memleak(func) - self.assertFalse(bytes, "Leaks %d bytes" % bytes) # type: ignore + self.assertFalse(bytes, f"Leaks {bytes} bytes") # type: ignore def test_mixedinout(self): o = self.create_object() @@ -186,7 +186,7 @@ def func(): return v.value bytes = find_memleak(func) - self.assertFalse(bytes, "Leaks %d bytes" % bytes) + self.assertFalse(bytes, f"Leaks {bytes} bytes") # type: ignore class SafeArrayTest(unittest.TestCase): @@ -207,7 +207,7 @@ def doit(): t.from_param([MYCOLOR(0, 0, 0), MYCOLOR(1, 2, 3)]) bytes = find_memleak(doit) - self.assertFalse(bytes, "Leaks %d bytes" % bytes) + self.assertFalse(bytes, f"Leaks {bytes} bytes") # type: ignore class PropPutRefTest(unittest.TestCase): diff --git a/comtypes/test/test_createwrappers.py b/comtypes/test/test_createwrappers.py index f2a64bd8c..9143f478a 100644 --- a/comtypes/test/test_createwrappers.py +++ b/comtypes/test/test_createwrappers.py @@ -55,8 +55,8 @@ def test(self): return comtypes.client.GetModule(fname) - test.__doc__ = "test GetModule(%r)" % fname - setattr(Test, "test_%d" % number, test) + test.__doc__ = f"test GetModule({fname!r})" + setattr(Test, f"test_{number}", test) number += 1