77import datetime
88import decimal
99import os
10- import platform
1110import time
12- from unittest import SkipTest
1311
1412import pythoncom
1513import win32com
1614import win32com .test .util
1715import win32timezone
1816import winerror
1917from win32api import CloseHandle , GetCurrentProcessId , OpenProcess
20- from win32com import universal
2118from win32com .client import (
2219 VARIANT ,
2320 CastTo ,
@@ -174,7 +171,7 @@ def _DumpFireds(self):
174171 if not self .fireds :
175172 print ("ERROR: Nothing was received!" )
176173 for firedId , no in self .fireds .items ():
177- progress ("ID %d fired %d times" % ( firedId , no ) )
174+ progress (f "ID { firedId } fired { no } times" )
178175
179176
180177# Test everything which can be tested using both the "dynamic" and "generated"
@@ -890,36 +887,29 @@ def TestVTableMI():
890887 pass
891888
892889
893- def TestQueryInterface (long_lived_server = 0 , iterations = 5 ):
890+ def TestQueryInterface (long_lived_server : bool = False , iterations = 5 ):
894891 tester = win32com .client .Dispatch ("PyCOMTest.PyCOMTest" )
895892 if long_lived_server :
896893 # Create a local server
897894 t0 = win32com .client .Dispatch (
898895 "Python.Test.PyCOMTest" , clsctx = pythoncom .CLSCTX_LOCAL_SERVER
899896 )
900- # Request custom interfaces a number of times
901- prompt = [
902- "Testing QueryInterface without long-lived local-server #%d of %d..." ,
903- "Testing QueryInterface with long-lived local-server #%d of %d..." ,
904- ]
897+ # Request custom interfaces a number of time
905898
906899 for i in range (iterations ):
907- progress (prompt [long_lived_server != 0 ] % (i + 1 , iterations ))
900+ progress (
901+ f"Testing QueryInterface "
902+ + ("with" if long_lived_server else "without" )
903+ + f" long-lived local-server #{ i + 1 } of { iterations } ..."
904+ )
908905 tester .TestQueryInterface ()
909906
910907
911908class Tester (win32com .test .util .TestCase ):
912909 def testRegisterInterfacesAfterGencache (self ) -> None :
913910 # We had a bug where RegisterInterfaces would fail if gencache had
914911 # already been run - exercise that here
915- try :
916- RegisterInterfaces ("{6BCDCB60-5605-11D0-AE5F-CADD4C000000}" , 0 , 1 , 1 )
917- except NotImplementedError :
918- if platform .machine () == "ARM64" :
919- raise SkipTest (
920- "`win32com.universal.RegisterInterfaces` doesn't support ARM64 yet"
921- )
922- raise
912+ RegisterInterfaces ("{6BCDCB60-5605-11D0-AE5F-CADD4C000000}" , 0 , 1 , 1 )
923913
924914 def testVTableInProc (self ) -> None :
925915 # We used to crash running this the second time - do it a few times
@@ -941,15 +931,15 @@ def testVTableMI(self):
941931 TestVTableMI ()
942932
943933 def testMultiQueryInterface (self ):
944- TestQueryInterface (0 , 6 )
934+ TestQueryInterface (False , 6 )
945935 # When we use the custom interface in the presence of a long-lived
946936 # local server, i.e. a local server that is already running when
947937 # we request an instance of our COM object, and remains afterwards,
948938 # then after repeated requests to create an instance of our object
949939 # the custom interface disappears -- i.e. QueryInterface fails with
950940 # E_NOINTERFACE. Set the upper range of the following test to 2 to
951- # pass this test, i.e. TestQueryInterface(1, 2)
952- TestQueryInterface (1 , 6 )
941+ # pass this test, i.e. TestQueryInterface(True, 2)
942+ TestQueryInterface (True , 6 )
953943
954944 def testDynamic (self ):
955945 TestDynamic ()
0 commit comments