Skip to content

Commit

Permalink
replaced by fstring (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
newwingbird authored Dec 16, 2024
1 parent 6ae68e4 commit 93da17f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion comtypes/test/test_BSTR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion comtypes/test/test_avmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
8 changes: 3 additions & 5 deletions comtypes/test/test_casesensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
6 changes: 3 additions & 3 deletions comtypes/test/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions comtypes/test/test_comserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions comtypes/test/test_createwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 93da17f

Please sign in to comment.