Skip to content

Commit e701123

Browse files
committed
Maybe fix tests
1 parent fca0484 commit e701123

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

com/win32com/test/testPyComTest.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import datetime
88
import decimal
99
import os
10+
import platform
1011
import time
12+
from unittest import SkipTest
1113

1214
import pythoncom
13-
import pywintypes
1415
import win32com
15-
import win32com.client.connect
1616
import win32com.test.util
1717
import win32timezone
1818
import winerror
@@ -23,8 +23,10 @@
2323
DispatchBaseClass,
2424
Record,
2525
constants,
26+
gencache,
2627
register_record_class,
2728
)
29+
from win32com.universal import RegisterInterfaces
2830
from win32process import GetProcessMemoryInfo
2931

3032
importMsg = "**** PyCOMTest is not installed ***\n PyCOMTest is a Python test specific COM client and server.\n It is likely this server is not installed on this machine\n To install the server, you must get the win32com sources\n and build it using MS Visual C++"
@@ -35,8 +37,6 @@
3537
"Python.Test.PyCOMTest",
3638
)
3739

38-
from win32com.client import gencache
39-
4040
try:
4141
gencache.EnsureModule(
4242
"{6BCDCB60-5605-11D0-AE5F-CADD4C000000}", 0, 1, 1, bForDemand=False
@@ -46,12 +46,6 @@
4646
print(importMsg)
4747
raise RuntimeError(importMsg)
4848

49-
# We had a bg where RegisterInterfaces would fail if gencache had
50-
# already been run - exercise that here
51-
from win32com import universal
52-
53-
universal.RegisterInterfaces("{6BCDCB60-5605-11D0-AE5F-CADD4C000000}", 0, 1, 1)
54-
5549
verbose = 0
5650

5751

@@ -886,15 +880,27 @@ def TestQueryInterface(long_lived_server=0, iterations=5):
886880

887881

888882
class Tester(win32com.test.util.TestCase):
889-
def testVTableInProc(self):
883+
def testRegisterInterfacesAfterGencache(self) -> None:
884+
# We had a bug where RegisterInterfaces would fail if gencache had
885+
# already been run - exercise that here
886+
try:
887+
RegisterInterfaces("{6BCDCB60-5605-11D0-AE5F-CADD4C000000}", 0, 1, 1)
888+
except NotImplementedError:
889+
if platform.machine() == "ARM64":
890+
raise SkipTest(
891+
"`win32com.universal.RegisterInterfaces` doesn't support ARM64 yet"
892+
)
893+
raise
894+
895+
def testVTableInProc(self) -> None:
890896
# We used to crash running this the second time - do it a few times
891897
for i in range(3):
892-
progress("Testing VTables in-process #%d..." % (i + 1))
898+
progress(f"Testing VTables in-process #{(i + 1)}...")
893899
TestVTable(pythoncom.CLSCTX_INPROC_SERVER)
894900

895-
def testVTableLocalServer(self):
901+
def testVTableLocalServer(self) -> None:
896902
for i in range(3):
897-
progress("Testing VTables out-of-process #%d..." % (i + 1))
903+
progress(f"Testing VTables out-of-process #{(i + 1)}...")
898904
TestVTable(pythoncom.CLSCTX_LOCAL_SERVER)
899905

900906
def testVTable2(self):

0 commit comments

Comments
 (0)