|
7 | 7 | import datetime |
8 | 8 | import decimal |
9 | 9 | import os |
| 10 | +import platform |
10 | 11 | import time |
| 12 | +from unittest import SkipTest |
11 | 13 |
|
12 | 14 | import pythoncom |
13 | | -import pywintypes |
14 | 15 | import win32com |
15 | | -import win32com.client.connect |
16 | 16 | import win32com.test.util |
17 | 17 | import win32timezone |
18 | 18 | import winerror |
|
23 | 23 | DispatchBaseClass, |
24 | 24 | Record, |
25 | 25 | constants, |
| 26 | + gencache, |
26 | 27 | register_record_class, |
27 | 28 | ) |
| 29 | +from win32com.universal import RegisterInterfaces |
28 | 30 | from win32process import GetProcessMemoryInfo |
29 | 31 |
|
30 | 32 | 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 | 37 | "Python.Test.PyCOMTest", |
36 | 38 | ) |
37 | 39 |
|
38 | | -from win32com.client import gencache |
39 | | - |
40 | 40 | try: |
41 | 41 | gencache.EnsureModule( |
42 | 42 | "{6BCDCB60-5605-11D0-AE5F-CADD4C000000}", 0, 1, 1, bForDemand=False |
|
46 | 46 | print(importMsg) |
47 | 47 | raise RuntimeError(importMsg) |
48 | 48 |
|
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 | | - |
55 | 49 | verbose = 0 |
56 | 50 |
|
57 | 51 |
|
@@ -886,15 +880,27 @@ def TestQueryInterface(long_lived_server=0, iterations=5): |
886 | 880 |
|
887 | 881 |
|
888 | 882 | 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: |
890 | 896 | # We used to crash running this the second time - do it a few times |
891 | 897 | for i in range(3): |
892 | | - progress("Testing VTables in-process #%d..." % (i + 1)) |
| 898 | + progress(f"Testing VTables in-process #{(i + 1)}...") |
893 | 899 | TestVTable(pythoncom.CLSCTX_INPROC_SERVER) |
894 | 900 |
|
895 | | - def testVTableLocalServer(self): |
| 901 | + def testVTableLocalServer(self) -> None: |
896 | 902 | 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)}...") |
898 | 904 | TestVTable(pythoncom.CLSCTX_LOCAL_SERVER) |
899 | 905 |
|
900 | 906 | def testVTable2(self): |
|
0 commit comments